NewBuy.vb
- Public Class NewBuy
- Dim ProgramName As String = My.Application.Info.AssemblyName
- Dim DataPath As String = System.Environment.CurrentDirectory & "\UAM"
- Dim ProductPath As String = DataPath & "\Products" '
- Dim ServicesPath As String = DataPath & "\Services"
- Dim CatPath As String = DataPath & "\Categories"
- Dim StoresPath As String = DataPath & "\Stores"
- Dim CustomersPath As String = DataPath & "\Customers"
- Dim CompanyPath As String = DataPath & "\Company"
- Dim MovmentPath As String = DataPath & "\Movment"
- Dim RequestsPath As String = DataPath & "\Requests"
- Dim VendorsPath As String = DataPath & "\Vendors"
- Dim BoxPath As String = DataPath & "\Box"
- Dim AlertsPath As String = DataPath & "\Alerts"
- Dim SettingsPath As String = DataPath & "\Settings"
- Dim AddToVindorBoolean As Boolean = False
- Friend WithEvents PrintPreviewControl1 As PrintPreviewControl
- Private WithEvents docToPrint As New Printing.PrintDocument
- Private Shared NewBuyInstance As NewBuy
- Public Shared Function GetInstance() As NewBuy
- If (NewBuyInstance Is Nothing) Then
- NewBuyInstance = New NewBuy
- End If
- Return NewBuyInstance
- End Function
- Private Sub NewSell_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Dim MyWidth As Integer = 0
- MyWidth = Val(LV.Width - TotalPayment.Width - 12) / 4
- LV.Columns.Item(0).Width = MyWidth * 1.5
- LV.Columns.Item(1).Width = MyWidth * 0.8
- LV.Columns.Item(2).Width = MyWidth * 0.7
- LV.Columns.Item(3).Width = MyWidth
- 'LV.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
- LoadVendors()
- LoadProducts()
- LoadPaymentWay()
- LoadStores()
- NewSellProNameTXT.Select()
- End Sub
- Private Sub CloseSaveBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseSaveBTN.Click
- 'Save Operator will be here
- StartUp.CloseTabs()
- End Sub
- Public Sub LoadVendors()
- Dim Addad As Integer = 0
- For Addad = 0 To My.Computer.FileSystem.GetDirectories(VendorsPath).Count - 1
- Dim VName As String = ""
- VName = My.Computer.FileSystem.GetDirectoryInfo(My.Computer.FileSystem.GetDirectories(VendorsPath).Item(Addad)).Name
- NewSellCusTXT.Items.Add(VName)
- Next
- End Sub
- Public Sub LoadProducts()
- Dim Addad As Integer = 0
- For Addad = 0 To My.Computer.FileSystem.GetDirectories(ProductPath).Count - 1
- Dim ProductName As String = ""
- If My.Computer.FileSystem.FileExists(My.Computer.FileSystem.GetDirectories(ProductPath).Item(Addad) & "\price.dat") = True Then
- ProductName = My.Computer.FileSystem.GetDirectoryInfo(My.Computer.FileSystem.GetDirectories(ProductPath).Item(Addad)).Name
- NewSellProNameTXT.Items.Add(ProductName)
- End If
- Next
- End Sub
- Public Sub LoadPaymentWay()
- NewSellPayWayTXT.Items.Clear()
- NewSellPayWayTXT.Items.AddRange(System.IO.File.ReadAllLines(DataPath & "\PaymentWay.dat", System.Text.Encoding.GetEncoding(0)))
- End Sub
- Public Sub LoadStores()
- StoreNameTXT.Text = My.Computer.FileSystem.ReadAllText(DataPath & "\defaultstore.dat", System.Text.Encoding.GetEncoding(0))
- Dim Addad As Integer = 0
- For Addad = 0 To My.Computer.FileSystem.GetDirectories(StoresPath).Count - 1
- Dim StoreName As String = ""
- StoreName = My.Computer.FileSystem.GetDirectoryInfo(My.Computer.FileSystem.GetDirectories(StoresPath).Item(Addad)).Name
- StoreNameTXT.Items.Add(StoreName)
- Next
- End Sub
- Private Sub NewSellProNameTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles NewSellProNameTXT.KeyDown
- If e.KeyCode = Keys.Enter Then NewSellAmountTXT.Select()
- End Sub
- Private Sub NewSellProNameTXT_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewSellProNameTXT.SelectedIndexChanged
- ProductPicPIC.Image = System.Drawing.Bitmap.FromFile(ProductPath & "\" & NewSellProNameTXT.Text & "\img.pic")
- NewSellBarcodeTXT.Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & NewSellProNameTXT.Text & "\barcode.dat", System.Text.Encoding.GetEncoding(0))
- End Sub
- Public Sub AddNewBTNClick()
- If My.Computer.FileSystem.DirectoryExists(ProductPath & "\" & NewSellProNameTXT.Text) = False Or My.Computer.FileSystem.FileExists(ProductPath & "\" & NewSellProNameTXT.Text & "\price.dat") = False Then GoTo AddNewProduct
- Dim MyItem As ListViewItem = LV.FindItemWithText(NewSellProNameTXT.Text)
- Dim ProductValue As Double = Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & NewSellProNameTXT.Text & "\price.dat", System.Text.Encoding.GetEncoding(0)))
- Dim TotalValue = ProductValue * Val(NewSellAmountTXT.Text)
- If Not MyItem Is Nothing Then
- LV.FindItemWithText(NewSellProNameTXT.Text).SubItems.Item(2).Text += Val(NewSellAmountTXT.Text)
- TotalValue = ProductValue * Val(LV.FindItemWithText(NewSellProNameTXT.Text).SubItems.Item(2).Text)
- LV.FindItemWithText(NewSellProNameTXT.Text).SubItems.Item(3).Text = TotalValue
- Else
- LV.Items.Add(NewSellProNameTXT.Text)
- LV.Items.Item(LV.Items.Count - 1).SubItems.Add(ProductValue)
- LV.Items.Item(LV.Items.Count - 1).SubItems.Add(NewSellAmountTXT.Text)
- LV.Items.Item(LV.Items.Count - 1).SubItems.Add(TotalValue)
- End If
- NewSellProNameTXT.Text = ""
- NewSellBarcodeTXT.Text = ""
- NewSellAmountTXT.Text = ""
- ProductPicPIC.Image = Nothing
- CalcItems()
- Me.Height += 32
- NewSellProNameTXT.Select()
- NewBTN.Enabled = True
- GoTo Finish
- AddNewProduct:
- StartUp.OpenNewTab(NewProduct.GetInstance)
- NewProduct.GetInstance.CalledFromWindow("buy", NewSellProNameTXT.Text)
- Finish:
- End Sub
- Private Sub AddNewBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddNewBTN.Click
- AddNewBTNClick()
- End Sub
- Public Sub CalcItems()
- Dim Addad As Integer = 0
- Dim TotlaPayment As Double = 0
- For Addad = 0 To LV.Items.Count - 1
- TotlaPayment += Val(LV.Items.Item(Addad).SubItems.Item(3).Text)
- Next
- TotalPayment.Text = "قيمة الفاتورة : " & TotlaPayment & " " & My.Computer.FileSystem.ReadAllText(SettingsPath & "\maincurrency.dat", System.Text.Encoding.GetEncoding(0))
- TotalPayment.Tag = TotlaPayment
- NewSellPayAmountTXT.Text = TotlaPayment
- End Sub
- Private Sub NewSellBarcodeTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles NewSellBarcodeTXT.KeyDown
- If e.KeyCode = Keys.Enter Then NewSellAmountTXT.Select()
- End Sub
- Private Sub NewSellBarcodeTXT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewSellBarcodeTXT.TextChanged
- Dim PL As New ListBox
- PL.Items.AddRange(System.IO.Directory.GetDirectories(ProductPath))
- Dim Addad As Integer = 0
- For Addad = 0 To PL.Items.Count - 1
- Dim ReeadBarcode As Integer = 0
- ReeadBarcode = Val(My.Computer.FileSystem.ReadAllText(PL.Items.Item(Addad) & "\barcode.dat", System.Text.Encoding.GetEncoding(0)))
- If ReeadBarcode = Val(NewSellBarcodeTXT.Text) Then
- NewSellProNameTXT.Text = My.Computer.FileSystem.GetDirectoryInfo(PL.Items.Item(Addad)).Name
- GoTo Finish
- End If
- Next
- Finish:
- End Sub
- Private Sub NewSellAmountTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles NewSellAmountTXT.KeyDown
- If e.KeyCode = Keys.Enter Then AddNewBTN.Select()
- End Sub
- Private Sub NewBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewBTN.Click
- If PrintCB.Checked = True Then
- PrintIt()
- End If
- SaveChanges()
- End Sub
- Public Sub PrintIt()
- PPD.Location = New Point(88, 80)
- PPD.Name = "PrintPreviewControl1"
- PPD.Document = docToPrint
- PPD.Document.DocumentName = "c:\someFile"
- PPD.UseAntiAlias = True
- PPD.ShowDialog()
- End Sub
- Private Sub docToPrint_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles docToPrint.PrintPage
- Dim NewForm As New Form
- Dim MyLV As New ListView
- Dim MyLBL As New Label
- Dim Addad As Integer = 0
- Dim SubAddad As Integer = 0
- Dim CName As New Label
- Dim CPic As New PictureBox
- Dim CAdd As New Label
- '...................................................................
- CName.AutoSize = False
- CAdd.AutoSize = False
- CPic.SizeMode = PictureBoxSizeMode.StretchImage
- CName.Left = 45
- CName.Top = 10
- CName.Width = 500
- CName.Height = 27
- CName.Font = New Font("Tahoma", 14, FontStyle.Bold, GraphicsUnit.Pixel, 0)
- CName.ForeColor = Color.Black
- CName.RightToLeft = Windows.Forms.RightToLeft.Yes
- CName.Text = My.Computer.FileSystem.ReadAllText(CompanyPath & "\name.dat", System.Text.Encoding.GetEncoding(0))
- CName.BackColor = Color.White
- CAdd.Left = 45
- CAdd.Top = 40
- CAdd.Width = 500
- CAdd.Height = 27
- CAdd.Font = New Font("Tahoma", 12, FontStyle.Regular, GraphicsUnit.Pixel, 0)
- CAdd.ForeColor = Color.Black
- CAdd.RightToLeft = Windows.Forms.RightToLeft.Yes
- CAdd.Text = "عنوان : " & My.Computer.FileSystem.ReadAllText(CompanyPath & "\address.dat", System.Text.Encoding.GetEncoding(0)) & " - هـ : " & My.Computer.FileSystem.ReadAllText(CompanyPath & "\tel.dat", System.Text.Encoding.GetEncoding(0))
- CAdd.BackColor = Color.White
- CPic.Image = System.Drawing.Bitmap.FromFile(CompanyPath & "\img.pic")
- CPic.Top = 10
- CPic.Left = CName.Left + CName.Width + 5
- CPic.Width = 50
- CPic.Height = 50
- CPic.BorderStyle = Windows.Forms.BorderStyle.FixedSingle
- '...................................................................
- MyLV.GridLines = LV.GridLines
- MyLV.View = LV.View
- MyLV.Font = LV.Font
- MyLV.RightToLeft = LV.RightToLeft
- MyLV.RightToLeftLayout = LV.RightToLeftLayout
- For Addad = 0 To LV.Columns.Count - 1
- MyLV.Columns.Add(LV.Columns.Item(Addad).Text)
- Next
- For Addad = 0 To LV.Items.Count - 1
- MyLV.Items.Add(LV.Items.Item(Addad).Text)
- For SubAddad = 1 To LV.Items.Item(Addad).SubItems.Count - 1
- MyLV.Items.Item(MyLV.Items.Count - 1).SubItems.Add(LV.Items.Item(Addad).SubItems.Item(SubAddad))
- Next
- Next
- MyLV.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
- NewForm.Width = LV.Width + 20
- NewForm.Height = LV.Height + 100
- NewForm.BackColor = Color.White
- MyLV.Width = NewForm.Width - 20
- MyLV.Left = 10
- MyLV.Top = 50
- MyLV.Anchor = AnchorStyles.Bottom And AnchorStyles.Right And AnchorStyles.Left And AnchorStyles.Top
- MyLV.Height = LV.Height
- MyLBL.Font = TotalPayment.Font
- MyLBL.Text = TotalPayment.Text & " ، تم الدفع للتاجر " & NewSellCusTXT.Text & " بطريقة : " & NewSellPayWayTXT.Text & " " & My.Computer.FileSystem.ReadAllText(SettingsPath & "\footer.dat", System.Text.Encoding.GetEncoding(0))
- MyLBL.TextAlign = ContentAlignment.MiddleRight
- MyLBL.BorderStyle = Windows.Forms.BorderStyle.None
- NewForm.FormBorderStyle = FormBorderStyle.None
- NewForm.Controls.Add(MyLV)
- NewForm.Controls.Add(MyLBL)
- NewForm.Controls.Add(CName)
- NewForm.Controls.Add(CAdd)
- NewForm.Controls.Add(CPic)
- MyLBL.Dock = DockStyle.Bottom
- MyLBL.Select()
- NewForm.Show()
- Dim MyBTMP As New Bitmap(NewForm.Width, NewForm.Height)
- NewForm.DrawToBitmap(MyBTMP, NewForm.ClientRectangle)
- e.Graphics.DrawImage(MyBTMP, New Point(100, 100))
- NewForm.Hide()
- End Sub
- Public Sub SaveChanges()
- Dim Addad As Integer = 0
- Dim SaveAndAdd As Boolean = False
- Dim MyTotlaPayment As Double = 0
- For Addad = 0 To LV.Items.Count - 1
- MyTotlaPayment += Val(LV.Items.Item(Addad).SubItems.Item(3).Text)
- Next
- If Val(My.Computer.FileSystem.ReadAllText(BoxPath & "\capital.dat", System.Text.Encoding.GetEncoding(0))) < MyTotlaPayment And NewSellPayWayTXT.Text <> "دين" Then GoTo EndPoint
- For Addad = 0 To LV.Items.Count - 1
- Dim PName As String = ""
- Dim Amount As Double = 0
- Dim LasAmount As Double = 0
- Dim SoldAmount As Double = 0
- Dim TAddad As Integer = 0
- PName = LV.Items.Item(Addad).Text
- Amount = Val(LV.Items.Item(Addad).SubItems.Item(2).Text)
- SoldAmount = Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\sold.dat", System.Text.Encoding.GetEncoding(0)))
- Dim MyStoreName As String = StoreNameTXT.Text
- Dim FName As String = ""
- If MyStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\store.dat", System.Text.Encoding.GetEncoding(0)) Then FName = "mount.dat" : GoTo Finish
- If Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\stores.dat", System.Text.Encoding.GetEncoding(0))) = 0 Then
- If My.Computer.FileSystem.FileExists(ProductPath & "\" & PName & "\mount0.dat") = True Then
- If MyStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\store0.dat", System.Text.Encoding.GetEncoding(0)) Then FName = "mount0.dat" : GoTo Finish
- End If
- Else
- Dim SubAddad As Integer = 0
- For SubAddad = 0 To Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\stores.dat", System.Text.Encoding.GetEncoding(0)))
- If MyStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\store" & SubAddad & ".dat", System.Text.Encoding.GetEncoding(0)) Then FName = "mount" & SubAddad & ".dat" : GoTo Finish
- Next
- End If
- ';;;;;;;;;;;;;;;;;;;;;;;;;;
- 'Store not contains product
- 'add product to store :
- ';;;;;;;;;;;;;;;;;;;;;;;;;;
- TAddad = Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\stores.dat", System.Text.Encoding.GetEncoding(0))) + 1
- My.Computer.FileSystem.WriteAllText(ProductPath & "\" & PName & "\store" & TAddad & ".dat", MyStoreName, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(ProductPath & "\" & PName & "\mount" & TAddad & ".dat", 0, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(ProductPath & "\" & PName & "\unit" & TAddad & ".dat", "", False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(ProductPath & "\" & PName & "\stores.dat", TAddad, False, System.Text.Encoding.GetEncoding(0))
- FName = "mount" & TAddad & ".dat"
- Finish:
- LasAmount = Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\" & FName, System.Text.Encoding.GetEncoding(0)))
- My.Computer.FileSystem.WriteAllText(ProductPath & "\" & PName & "\" & FName, LasAmount + Amount, False)
- '...........................................
- 'Writting Buy Hestory
- '...........................................
- Dim YearSTR As String = Date.Now.Year
- Dim MonthSTR As String = Date.Now.Month
- Dim DaySTR As String = Date.Now.Day
- Dim HourSTR As String = Date.Now.Hour
- Dim MinuteSTR As String = Date.Now.Minute
- Dim SecondSTR As String = Date.Now.Second
- Dim MillisecondSTR As String = Date.Now.Millisecond
- If MonthSTR.Length <= 1 Then MonthSTR = "0" & MonthSTR
- If DaySTR.Length <= 1 Then DaySTR = "0" & DaySTR
- If HourSTR.Length <= 1 Then HourSTR = "0" & HourSTR
- If MinuteSTR.Length <= 1 Then MinuteSTR = "0" & MinuteSTR
- If SecondSTR.Length <= 1 Then SecondSTR = "0" & SecondSTR
- Dim DateDir As String = MovmentPath & "\" & YearSTR & "\" & MonthSTR & "\" & DaySTR
- Dim MonthDir As String = MovmentPath & "\" & YearSTR & "\" & MonthSTR
- Dim YearDir As String = MovmentPath & "\" & YearSTR
- Dim WDir As String = MovmentPath & "\" & YearSTR & "\" & MonthSTR & "\" & DaySTR & "\" & HourSTR & MinuteSTR & SecondSTR & MillisecondSTR
- My.Computer.FileSystem.CreateDirectory(WDir)
- My.Computer.FileSystem.WriteAllText(WDir & "\type.dat", "buy", False)
- My.Computer.FileSystem.WriteAllText(WDir & "\product.dat", PName, False)
- My.Computer.FileSystem.WriteAllText(WDir & "\amount.dat", Amount, False)
- My.Computer.FileSystem.WriteAllText(WDir & "\payment.dat", Val(LV.Items.Item(Addad).SubItems.Item(3).Text), False)
- Dim InterValue As Double = 0
- Dim TaxValue As Double = 0
- TaxValue = Val(Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\price.dat", System.Text.Encoding.GetEncoding(0))) * Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\maintax.dat", System.Text.Encoding.GetEncoding(0))) / 100) + Val(Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\price.dat", System.Text.Encoding.GetEncoding(0))) * Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\subtax.dat", System.Text.Encoding.GetEncoding(0))) / 100)
- InterValue = Val(LV.Items.Item(Addad).SubItems.Item(3).Text) - Val(Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\price.dat", System.Text.Encoding.GetEncoding(0))) * Amount) - (TaxValue * Amount)
- My.Computer.FileSystem.WriteAllText(WDir & "\inter.dat", InterValue, False)
- My.Computer.FileSystem.WriteAllText(WDir & "\customer.dat", NewSellCusTXT.Text, False)
- My.Computer.FileSystem.WriteAllText(WDir & "\store.dat", StoreNameTXT.Text, False)
- My.Computer.FileSystem.WriteAllText(WDir & "\price.dat", Val(LV.Items.Item(Addad).SubItems.Item(1).Text), False)
- Dim ProductReq As Integer = 0
- If My.Computer.FileSystem.DirectoryExists(RequestsPath & "\" & PName) = True Then
- ProductReq = Val(My.Computer.FileSystem.ReadAllText(RequestsPath & "\" & PName & "\amount.dat", System.Text.Encoding.GetEncoding(0)))
- If ProductReq <= LasAmount + Amount Then
- System.IO.Directory.Delete(RequestsPath & "\" & PName, True)
- Else
- My.Computer.FileSystem.WriteAllText(RequestsPath & "\" & PName & "\amount.dat", ProductReq - LasAmount + Amount, False)
- End If
- End If
- Dim TWDir As String = ""
- TWDir = AlertsPath & "\" & PName & "\P-need"
- If My.Computer.FileSystem.DirectoryExists(TWDir) Then System.IO.Directory.Delete(TWDir, True)
- StartUp.LoadAlerts()
- '.....................................................
- '.....................................................
- 'Write Data To Box :..................................
- '.....................................................
- '.....................................................
- 'Here i will write dept code """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- If NewSellPayWayTXT.Text = "دين" Then GoTo DeptPoint
- Dim LastDayInterValue As Double = 0
- 'money
- If My.Computer.FileSystem.FileExists(DateDir & "\money.dat") = True Then
- LastDayInterValue = Val(My.Computer.FileSystem.ReadAllText(DateDir & "\money.dat", System.Text.Encoding.GetEncoding(0)))
- Else
- LastDayInterValue = 0
- End If
- My.Computer.FileSystem.WriteAllText(DateDir & "\money.dat", LastDayInterValue - Val(LV.Items.Item(Addad).SubItems.Item(3).Text), False)
- My.Computer.FileSystem.WriteAllText(BoxPath & "\money.dat", LastDayInterValue - Val(LV.Items.Item(Addad).SubItems.Item(3).Text), False)
- 'capital
- If My.Computer.FileSystem.FileExists(DateDir & "\capital.dat") = True Then
- LastDayInterValue = Val(My.Computer.FileSystem.ReadAllText(DateDir & "\capital.dat", System.Text.Encoding.GetEncoding(0)))
- Else
- LastDayInterValue = 0
- End If
- My.Computer.FileSystem.WriteAllText(DateDir & "\capital.dat", LastDayInterValue - Val(LV.Items.Item(Addad).SubItems.Item(3).Text), False)
- My.Computer.FileSystem.WriteAllText(BoxPath & "\capital.dat", LastDayInterValue - Val(LV.Items.Item(Addad).SubItems.Item(3).Text), False)
- DeptPoint:
- If AddToVindorBoolean = False Then AddToVindor(YearSTR & MonthSTR & DaySTR & HourSTR & MinuteSTR)
- Complete:
- Next
- AddToVindorBoolean = False
- ZeroingValues()
- GoTo Endding
- EndPoint:
- MsgBox("إن قيمة الفاتورة أكبر من قيمة رأس المال في صندوقك ، يمكنك تحويل المال إلى خانة رأس المال بالدخول إلى الصندوق")
- Endding:
- End Sub
- Public Sub ZeroingValues()
- NewSellProNameTXT.Text = ""
- NewSellAmountTXT.Text = ""
- NewBTN.Enabled = False
- LV.Items.Clear()
- TotalPayment.Text = "قيمة الفاتورة : 0" & " " & My.Computer.FileSystem.ReadAllText(SettingsPath & "\maincurrency.dat", System.Text.Encoding.GetEncoding(0))
- 'LV.Height = 66
- Me.Height = 467
- End Sub
- Public Sub AddToVindor(ByVal SDate As String)
- Dim Addad As Integer = 0
- For Addad = 0 To LV.Items.Count - 1
- If LV.Items.Item(Addad).Text = "" Or LV.Items.Item(Addad).SubItems.Count < 1 Then GoTo EndOfAdd
- Dim CPath As String = VendorsPath & "\" & NewSellCusTXT.Text
- Dim DateSTR As String = SDate & Date.Now.Millisecond
- Dim PName As String = LV.Items.Item(Addad).Text
- Dim PAmount As Double = Val(LV.Items.Item(Addad).SubItems(2).Text)
- Dim PaymentTotal As Double = Val(LV.Items.Item(Addad).SubItems(3).Text)
- Dim PayDBL As Double = 0
- Dim RemainDBL As Double = 0
- If NewSellPayWayTXT.Text = "دين" Then
- PayDBL = 0
- RemainDBL = PaymentTotal
- Else
- PayDBL = PaymentTotal
- RemainDBL = 0
- End If
- If My.Computer.FileSystem.DirectoryExists(CPath) = True Then
- If My.Computer.FileSystem.DirectoryExists(CPath & "\payment") = False Then My.Computer.FileSystem.CreateDirectory(CPath & "\payment")
- Else
- 'Add New Vendor Then Write info : (when creating new Vendor from here notify user to complete the cinfo)
- My.Computer.FileSystem.CreateDirectory(CPath)
- If My.Computer.FileSystem.DirectoryExists(CPath & "\payment") = False Then My.Computer.FileSystem.CreateDirectory(CPath & "\payment")
- My.Computer.FileSystem.WriteAllText(CPath & "\name.dat", NewSellCusTXT.Text, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\address.dat", "", False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\tel.dat", "", False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\mail.dat", "", False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\web.dat", "", False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\job.dat", "", False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\jobaddress.dat", "", False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\totaldept.dat", 0, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\totalpayment.dat", 0, False, System.Text.Encoding.GetEncoding(0))
- End If
- My.Computer.FileSystem.CreateDirectory(CPath & "\payment\" & DateSTR)
- My.Computer.FileSystem.WriteAllText(CPath & "\payment\" & DateSTR & "\date.dat", DateSTR, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\payment\" & DateSTR & "\pname.dat", PName, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\payment\" & DateSTR & "\pamount.dat", PAmount, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\payment\" & DateSTR & "\paymenttotal.dat", PaymentTotal, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\payment\" & DateSTR & "\paydbl.dat", PayDBL, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(CPath & "\payment\" & DateSTR & "\remaindbl.dat", RemainDBL, False, System.Text.Encoding.GetEncoding(0))
- PayDBL += Val(My.Computer.FileSystem.ReadAllText(CPath & "\totalpayment.dat", System.Text.Encoding.GetEncoding(0)))
- RemainDBL += Val(My.Computer.FileSystem.ReadAllText(CPath & "\totaldept.dat", System.Text.Encoding.GetEncoding(0)))
- My.Computer.FileSystem.WriteAllText(CPath & "\totaldept.dat", RemainDBL, False, System.Text.Encoding.GetEncoding(0))
- Dim LTP As Double = Val(My.Computer.FileSystem.ReadAllText(CPath & "\totalpayment.dat", System.Text.Encoding.GetEncoding(0)))
- My.Computer.FileSystem.WriteAllText(CPath & "\totalpayment.dat", PaymentTotal + LTP, False, System.Text.Encoding.GetEncoding(0))
- 'My.Computer.FileSystem.WriteAllText(CPath & "\totalpayment.dat", PaymentTotal, False, System.Text.Encoding.GetEncoding(0))
- EndOfAdd:
- Next
- AddToVindorBoolean = True
- End Sub
- Public Sub AddToRequests(ByVal Pname As String, ByVal Amount As Double, ByVal SName As String)
- If My.Computer.FileSystem.DirectoryExists(RequestsPath & "\" & Pname) = False Then
- My.Computer.FileSystem.CreateDirectory(RequestsPath & "\" & Pname)
- My.Computer.FileSystem.WriteAllText(RequestsPath & "\" & Pname & "\amount.dat", 0, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(RequestsPath & "\" & Pname & "\customers.dat", "", False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(RequestsPath & "\" & Pname & "\stores.dat", "", False, System.Text.Encoding.GetEncoding(0))
- End If
- Dim LastAmount As Double = Val(My.Computer.FileSystem.ReadAllText(RequestsPath & "\" & Pname & "\amount.dat", System.Text.Encoding.GetEncoding(0)))
- Dim LastC As String = My.Computer.FileSystem.ReadAllText(RequestsPath & "\" & Pname & "\customers.dat", System.Text.Encoding.GetEncoding(0))
- Dim LastS As String = My.Computer.FileSystem.ReadAllText(RequestsPath & "\" & Pname & "\stores.dat", System.Text.Encoding.GetEncoding(0))
- LastAmount += Amount
- If LastC.Contains(NewSellCusTXT.Text) = False Then LastC = LastC & "," & NewSellCusTXT.Text
- If LastS.Contains(SName) = False Then LastS = LastS & "," & SName
- My.Computer.FileSystem.WriteAllText(RequestsPath & "\" & Pname & "\amount.dat", LastAmount, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(RequestsPath & "\" & Pname & "\customers.dat", LastC, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(RequestsPath & "\" & Pname & "\stores.dat", LastS, False, System.Text.Encoding.GetEncoding(0))
- 'write to customer path requesting info :
- 'by loading req dirs and compare files .
- MsgBox("كمية ال" & Pname & " المطلوب بيعها غير متوفرة في مخزن " & SName & " حالياً ، لقد تمت إضافة الطلب إلى قائمة طلبات السلع غير المتوفرة.")
- End Sub
- Private Sub NewSellPayWayTXT_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewSellPayWayTXT.SelectedIndexChanged
- If NewSellPayWayTXT.Text = "دين" Then
- NewSellPayAmountTXT.Enabled = False
- NewSellPayAmountTXT.Text = TotalPayment.Tag
- Else
- NewSellPayAmountTXT.Enabled = True
- End If
- End Sub
- Private Sub DelBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DelBTN.Click
- If LV.SelectedItems.Count > 0 Then
- LV.Items.Remove(LV.FocusedItem)
- If LV.Items.Count < 1 Then
- ZeroingValues()
- End If
- End If
- End Sub
- Private Sub NewSellCusTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles NewSellCusTXT.KeyDown
- If e.KeyCode = Keys.Enter Then NewSellProNameTXT.Select()
- End Sub
- Private Sub StoreNameTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles StoreNameTXT.KeyDown
- If e.KeyCode = Keys.Enter Then AddNewBTN.Select()
- End Sub
- End Class