NewProduct.vb
- Public Class NewProduct
- 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 AlertsPath As String = DataPath & "\Alerts"
- Dim StoreNumber As Integer = 0
- Dim CalledFrom As String = ""
- Dim LastPriceInformation() As Double = {0, 0, 0}
- Private Shared NewProductInstance As NewProduct
- Public Shared Function GetInstance() As NewProduct
- If (NewProductInstance Is Nothing) Then
- NewProductInstance = New NewProduct
- End If
- Return NewProductInstance
- End Function
- Public Sub CalledFromWindow(ByVal SName As String, ByVal Pname As String)
- CalledFrom = SName
- ProductNameTXT.Text = Pname
- ProductMountTXT.Text = 0
- ProductMountTXT.Enabled = False
- End Sub
- Public Sub AddNewProduct()
- Dim NewProductPath As String = ProductPath & "\" & ProductNameTXT.Text
- If My.Computer.FileSystem.DirectoryExists(NewProductPath) = False Then My.Computer.FileSystem.CreateDirectory(NewProductPath)
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\cat.dat", ProductCatTXT.Text, False)
- If My.Computer.FileSystem.FileExists(CatPath & "\" & ProductCatTXT.Text & ".dat") = True Then
- If ProductAddBTN.Text = "إضافة" Then
- My.Computer.FileSystem.WriteAllText(CatPath & "\" & ProductCatTXT.Text & ".dat", ProductNameTXT.Text & System.Environment.NewLine, True)
- End If
- Else
- My.Computer.FileSystem.WriteAllText(CatPath & "\" & ProductCatTXT.Text & ".dat", ProductNameTXT.Text & System.Environment.NewLine, False)
- End If
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\type.dat", ProductTypeTXT.Text, False)
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\barcode.dat", ProductCodeTXT.Text, False)
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\price.dat", ProductPriceTXT.Text, False)
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\maintax.dat", ProductTax1TXT.Text, False)
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\subtax.dat", ProductTax2TXT.Text, False)
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\purch.dat", ProductPurchTXT.Text, False)
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\store.dat", ProductStoreTXT.Text, False)
- If My.Computer.FileSystem.DirectoryExists(StoresPath & "\" & ProductStoreTXT.Text) = False Then
- My.Computer.FileSystem.CreateDirectory(StoresPath & "\" & ProductStoreTXT.Text)
- My.Computer.FileSystem.WriteAllText(StoresPath & "\" & ProductStoreTXT.Text & "\" & ProductNameTXT.Text & ".dat", ProductMountTXT.Text, False)
- Else
- If My.Computer.FileSystem.FileExists(StoresPath & "\" & ProductStoreTXT.Text & "\" & ProductNameTXT.Text & ".dat") = True Then
- Dim LastMount As Double = Val(My.Computer.FileSystem.ReadAllText(StoresPath & "\" & ProductStoreTXT.Text & "\" & ProductNameTXT.Text & ".dat", System.Text.Encoding.GetEncoding(0)))
- LastMount += Val(ProductMountTXT.Text)
- Else
- My.Computer.FileSystem.WriteAllText(StoresPath & "\" & ProductStoreTXT.Text & "\" & ProductNameTXT.Text & ".dat", ProductMountTXT.Text, False)
- End If
- End If
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\mount.dat", ProductMountTXT.Text, False)
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\unit.dat", ProductUnitsTXT.Text, False)
- 'Add New Stores To Files
- '"NewStoreTXT" & StoreNumber
- Dim VAddad As Integer = 0
- For VAddad = 0 To StoreNumber - 1
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\store" & VAddad & ".dat", Me.Controls.Item("NewStoreTXT" & VAddad).Text, False)
- If My.Computer.FileSystem.DirectoryExists(StoresPath & "\" & Me.Controls.Item("NewStoreTXT" & VAddad).Text) = False Then
- My.Computer.FileSystem.CreateDirectory(StoresPath & "\" & Me.Controls.Item("NewStoreTXT" & VAddad).Text)
- My.Computer.FileSystem.WriteAllText(StoresPath & "\" & Me.Controls.Item("NewStoreTXT" & VAddad).Text & "\" & ProductNameTXT.Text & ".dat", Me.Controls.Item("NewMountTXT" & VAddad).Text, False)
- Else
- If My.Computer.FileSystem.FileExists(StoresPath & "\" & Me.Controls.Item("NewStoreTXT" & VAddad).Text & "\" & ProductNameTXT.Text & ".dat") = True Then
- Dim LastMount As Double = Val(My.Computer.FileSystem.ReadAllText(StoresPath & "\" & Me.Controls.Item("NewStoreTXT" & VAddad).Text & "\" & ProductNameTXT.Text & ".dat", System.Text.Encoding.GetEncoding(0)))
- LastMount += Val(Me.Controls.Item("NewMountTXT" & VAddad).Text)
- Else
- My.Computer.FileSystem.WriteAllText(StoresPath & "\" & Me.Controls.Item("NewStoreTXT" & VAddad).Text & "\" & ProductNameTXT.Text & ".dat", Me.Controls.Item("NewMountTXT" & VAddad).Text, False)
- End If
- End If
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\mount" & VAddad & ".dat", Me.Controls.Item("NewMountTXT" & VAddad).Text, False)
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\unit" & VAddad & ".dat", Me.Controls.Item("NewUnitsTXT" & VAddad).Text, False)
- Next
- If StoreNumber < 1 Then
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\stores.dat", -1, False)
- Else
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\stores.dat", StoreNumber - 1, False)
- End If
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\request.dat", 0, False)
- My.Computer.FileSystem.WriteAllText(NewProductPath & "\sold.dat", 0, False)
- Finish:
- End Sub
- Public Sub ZeroingText()
- ProductNameTXT.Text = ""
- ProductCatTXT.Text = ""
- ProductTypeTXT.Text = ""
- ProductCodeTXT.Text = ""
- ProductPriceTXT.Text = ""
- ProductTax1TXT.Text = ""
- ProductTax2TXT.Text = ""
- ProductPurchTXT.Text = ""
- ProductMountTXT.Text = ""
- ProductStoreTXT.Text = ""
- ProductUnitsTXT.Text = ""
- RmoveComboText()
- ProductMountTXT.Enabled = True
- ProductPicPIC.Image = Nothing
- End Sub
- Private Sub ProductAddBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductAddBTN.Click
- TestText()
- AddNewProduct()
- ZeroingText()
- LoadStore(ProductStoreTXT)
- StartUp.RemoveTab()
- StartUp.MainPanel.Controls.Clear()
- If CalledFrom = "buy" Then
- StartUp.MainPanel.Controls.Add(NewBuy.GetInstance())
- StartUp.AddNewTab(NewBuy.GetInstance.Tag, NewBuy.GetInstance.Name)
- NewBuy.GetInstance.AddNewBTNClick()
- ElseIf CalledFrom = "sell" Then
- StartUp.MainPanel.Controls.Add(NewSell.GetInstance())
- StartUp.AddNewTab(NewSell.GetInstance.Tag, NewSell.GetInstance.Name)
- NewSell.GetInstance.AddNewBTNClick()
- ElseIf My.Computer.FileSystem.DirectoryExists(CalledFrom) = True Then
- System.IO.Directory.Delete(CalledFrom, True)
- StartUp.LoadAlerts()
- StartUp.MainPanel.Controls.Add(MainView.GetInstance())
- StartUp.AddNewTab(MainView.GetInstance.Tag, MainView.GetInstance.Name)
- Else
- StartUp.MainPanel.Controls.Add(MainView.GetInstance())
- StartUp.AddNewTab(MainView.GetInstance.Tag, MainView.GetInstance.Name)
- End If
- CalledFrom = ""
- End Sub
- Public Sub TestText()
- 'test values to add errors to Alerts :
- Dim PName As String = ProductNameTXT.Text
- Dim WDir As String = ""
- '××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- If ProductCatTXT.Text = "" Then
- StartUp.AlertsWriter(PName, "لم تقم بتصنيف الـ" & PName & " , أنقر هنا لتصنيف المنتج", "cat")
- Else
- WDir = AlertsPath & "\" & PName & "\cat"
- If My.Computer.FileSystem.DirectoryExists(WDir) Then System.IO.Directory.Delete(WDir, True)
- End If
- '××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- If ProductTypeTXT.Text = "" Then
- StartUp.AlertsWriter(PName, "لم تقم بوضع نمط للـ" & PName & " , أنقر هنا لوضع نمط المنتج", "type")
- Else
- WDir = AlertsPath & "\" & PName & "\type"
- If My.Computer.FileSystem.DirectoryExists(WDir) Then System.IO.Directory.Delete(WDir, True)
- End If
- '××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- If ProductCodeTXT.Text = "" Then
- StartUp.AlertsWriter(PName, "لم تقم بوضع باركود الـ" & PName & " , أنقر هنا لوضع باركود المنتج", "bar")
- Else
- WDir = AlertsPath & "\" & PName & "\bar"
- If My.Computer.FileSystem.DirectoryExists(WDir) Then System.IO.Directory.Delete(WDir, True)
- End If
- '××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- If ProductPriceTXT.Text = "" Then
- StartUp.AlertsWriter(PName, "لم تقم بوضع سعر الجملة لـ" & PName & " , أنقر هنا لوضع سعر جملة المنتج", "price")
- Else
- WDir = AlertsPath & "\" & PName & "\price"
- If My.Computer.FileSystem.DirectoryExists(WDir) Then System.IO.Directory.Delete(WDir, True)
- End If
- '××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- If ProductTax1TXT.Text = "" Then
- StartUp.AlertsWriter(PName, "لم تقم بتعيين قيمة الضريبة الرئيسية للـ" & PName & " , أنقر هنا لتعيين ضريبة المنتج الرئيسية", "tax")
- Else
- WDir = AlertsPath & "\" & PName & "\tax"
- If My.Computer.FileSystem.DirectoryExists(WDir) Then System.IO.Directory.Delete(WDir, True)
- End If
- '××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- If ProductTax2TXT.Text = "" Then
- StartUp.AlertsWriter(PName, "لم تقم بتعيين قيمة الضريبة الثانوية للـ" & PName & " , أنقر هنا لتعيين ضريبة المنتج الثانوية", "subtax")
- Else
- WDir = AlertsPath & "\" & PName & "\subtax"
- If My.Computer.FileSystem.DirectoryExists(WDir) Then System.IO.Directory.Delete(WDir, True)
- End If
- '××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- If ProductPurchTXT.Text = "" Then
- StartUp.AlertsWriter(PName, "لم تقم بتعيين سعر مبيع الـ" & PName & " , أنقر هنا لتعيين سعر المنتج", "purch")
- Else
- WDir = AlertsPath & "\" & PName & "\purch"
- If My.Computer.FileSystem.DirectoryExists(WDir) Then System.IO.Directory.Delete(WDir, True)
- End If
- '××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- If ProductStoreTXT.Text = "" Then
- StartUp.AlertsWriter(PName, "لم تقم بتحدبد المخزن الرئيسي للـ" & PName & " , أنقر هنا لتعيين مخزن المنتج الرئيسي", "store")
- Else
- WDir = AlertsPath & "\" & PName & "\store"
- If My.Computer.FileSystem.DirectoryExists(WDir) Then System.IO.Directory.Delete(WDir, True)
- End If
- '××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- If ProductMountTXT.Text = "" And CalledFrom = "" Then
- StartUp.AlertsWriter(PName, "لم تقم بتحدبد كمية الـ" & PName & " لديك , أنقر هنا لتعيين كمية المنتج ", "amount")
- Else
- WDir = AlertsPath & "\" & PName & "\amount"
- If My.Computer.FileSystem.DirectoryExists(WDir) Then System.IO.Directory.Delete(WDir, True)
- End If
- '××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- If ProductUnitsTXT.Text = "" Then
- StartUp.AlertsWriter(PName, "لم تقم بتحدبد وحدة الـ" & PName & " لديك , أنقر هنا لتعيين وحدة المنتج ", "unit")
- Else
- WDir = AlertsPath & "\" & PName & "\unit"
- If My.Computer.FileSystem.DirectoryExists(WDir) Then System.IO.Directory.Delete(WDir, True)
- End If
- '××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- StartUp.LoadAlerts()
- End Sub
- Private Sub ProductCancleBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductCancleBTN.Click
- StartUp.CloseTabs()
- LoadStore(ProductStoreTXT)
- ZeroingText()
- End Sub
- Public Sub LoadCategories()
- Dim Addad As Integer = 0
- ProductCatTXT.Items.Clear()
- For Addad = 0 To My.Computer.FileSystem.GetFiles(CatPath).Count - 1
- Dim CatName As String = My.Computer.FileSystem.GetFileInfo(My.Computer.FileSystem.GetFiles(CatPath).Item(Addad)).Name
- CatName = CatName.Remove(CatName.Length - 4, 4)
- ProductCatTXT.Items.Add(CatName)
- Next
- End Sub
- Public Sub LoadTypes()
- Dim Addad As Integer = 0
- ProductTypeTXT.Items.Clear()
- ProductTypeTXT.Items.Add("منتج / سلعة")
- ProductTypeTXT.Items.Add("خدمات")
- End Sub
- Public Sub LoadTax()
- Dim Addad As Integer = 0
- ProductTax1TXT.Items.Clear()
- ProductTax2TXT.Items.Clear()
- For Addad = 20 To 99 Step +20
- ProductTax1TXT.Items.Add("0." & Addad)
- ProductTax2TXT.Items.Add("0." & Addad)
- Next
- End Sub
- Public Sub LoadStore(ByVal sender As Object)
- Dim Addad As Integer = 0
- sender.Items.Clear()
- For Addad = 0 To My.Computer.FileSystem.GetDirectories(StoresPath).Count - 1
- Dim StoreName As String = My.Computer.FileSystem.GetDirectoryInfo(My.Computer.FileSystem.GetDirectories(StoresPath).Item(Addad)).Name
- sender.Items.Add(StoreName)
- Next
- End Sub
- Public Sub LoadUnits(ByVal sender As Object)
- sender.Items.AddRange(System.IO.File.ReadAllLines(DataPath & "\units.dat", System.Text.Encoding.GetEncoding(0)))
- End Sub
- Public Sub LoadProduct(ByRef Name As String)
- On Error Resume Next
- ProductNameTXT.Text = Name
- ProductCatTXT.Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\cat.dat", System.Text.Encoding.GetEncoding(0))
- ProductTypeTXT.Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\type.dat", System.Text.Encoding.GetEncoding(0))
- ProductCodeTXT.Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\barcode.dat", System.Text.Encoding.GetEncoding(0))
- ProductPriceTXT.Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\price.dat", System.Text.Encoding.GetEncoding(0))
- ProductTax1TXT.Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\maintax.dat", System.Text.Encoding.GetEncoding(0))
- ProductTax2TXT.Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\subtax.dat", System.Text.Encoding.GetEncoding(0))
- ProductPurchTXT.Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\purch.dat", System.Text.Encoding.GetEncoding(0))
- ProductStoreTXT.Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\store.dat", System.Text.Encoding.GetEncoding(0))
- ProductMountTXT.Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\mount.dat", System.Text.Encoding.GetEncoding(0))
- ProductUnitsTXT.Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\unit.dat", System.Text.Encoding.GetEncoding(0))
- ProductPicPIC.Image = System.Drawing.Bitmap.FromFile(ProductPath & "\" & Name & "\img.pic")
- CalcInter()
- Dim StoresNum As Integer = Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\stores.dat", System.Text.Encoding.GetEncoding(0)))
- Dim MinusAddad As Integer = 0
- If StoresNum > 0 Then
- For MinusAddad = 0 To StoresNum
- AddNewComboText()
- Me.Controls.Item("NewStoreTXT" & MinusAddad).Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\store" & MinusAddad & ".dat", System.Text.Encoding.GetEncoding(0))
- Me.Controls.Item("NewMountTXT" & MinusAddad).Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\mount" & MinusAddad & ".dat", System.Text.Encoding.GetEncoding(0))
- Me.Controls.Item("NewUnitsTXT" & MinusAddad).Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\unit" & MinusAddad & ".dat", System.Text.Encoding.GetEncoding(0))
- Next
- GoTo FinishLoadingSubStore
- ElseIf StoresNum = 0 Then
- If My.Computer.FileSystem.FileExists(ProductPath & "\" & Name & "\mount0.dat") = True Then
- AddNewComboText()
- Me.Controls.Item("NewStoreTXT0").Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\store0.dat", System.Text.Encoding.GetEncoding(0))
- Me.Controls.Item("NewMountTXT0").Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\mount0.dat", System.Text.Encoding.GetEncoding(0))
- Me.Controls.Item("NewUnitsTXT0").Text = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & Name & "\unit0.dat", System.Text.Encoding.GetEncoding(0))
- Else
- GoTo FinishLoadingSubStore
- End If
- End If
- FinishLoadingSubStore:
- CleanUpComboText()
- TestServicesIfActivate()
- End Sub
- Private Sub NewProduct_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- OFD.Multiselect = False
- OFD.InitialDirectory = "c:\"
- OFD.Title = "إنتقاء صورة للمنتج"
- OFD.Filter = "jpg files (*.jpg)|*.jpg|bmp files (*.bmp)|*.bmp|png files (*.png)|*.png"
- LoadCategories()
- LoadTypes()
- LoadTax()
- LoadStore(ProductStoreTXT)
- LoadUnits(ProductUnitsTXT)
- ProductNameTXT.Select()
- End Sub
- Private Sub ProductBrowseBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductBrowseBTN.Click
- OFD.ShowDialog()
- End Sub
- Private Sub OFD_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OFD.FileOk
- ProductCleanBTN_Click(sender, e)
- Dim NewProductPath As String = ProductPath & "\" & ProductNameTXT.Text
- My.Computer.FileSystem.CopyFile(OFD.FileName, NewProductPath & "\img.pic")
- ProductPicPIC.Image = System.Drawing.Bitmap.FromFile(NewProductPath & "\img.pic")
- End Sub
- Private Sub ProductCleanBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductCleanBTN.Click
- On Error Resume Next
- ProductPicPIC.Image = Nothing
- ProductPicPIC.Refresh()
- Dim TryNum As Integer = 0
- If My.Computer.FileSystem.FileExists(ProductPath & "\" & ProductNameTXT.Text & "\img.pic") = False Then GoTo Finish
- Retry:
- System.IO.File.SetAttributes(ProductPath & "\" & ProductNameTXT.Text & "\img.pic", IO.FileAttributes.Normal)
- System.IO.File.Delete(ProductPath & "\" & ProductNameTXT.Text & "\img.pic")
- If My.Computer.FileSystem.FileExists(ProductPath & "\" & ProductNameTXT.Text & "\img.pic") = True And TryNum < 100 Then TryNum += 1 : GoTo Retry Else MsgBox("لا يمكن التعامل مع الصورة حالياً أعد المحاولة بعد قليل")
- Finish:
- End Sub
- Private Sub ProductNameTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ProductNameTXT.KeyDown
- If e.KeyCode = Keys.Enter Then ProductCatTXT.Select()
- End Sub
- Private Sub ProductNameTXT_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ProductNameTXT.LostFocus
- If My.Computer.FileSystem.DirectoryExists(ProductPath & "\" & ProductNameTXT.Text) = False Then
- ProductCatTXT.Text = ""
- ProductTypeTXT.Text = ""
- ProductCodeTXT.Text = ""
- ProductPriceTXT.Text = ""
- ProductTax1TXT.Text = ""
- ProductTax2TXT.Text = ""
- ProductPurchTXT.Text = ""
- ProductMountTXT.Text = ""
- ProductStoreTXT.Text = ""
- ProductUnitsTXT.Text = ""
- RmoveComboText()
- ProductPicPIC.Image = Nothing
- ProductAddBTN.Text = "إضافة"
- End If
- End Sub
- Private Sub ProductNameTXT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductNameTXT.TextChanged
- If My.Computer.FileSystem.DirectoryExists(ProductPath & "\" & ProductNameTXT.Text) = True And ProductNameTXT.Text <> "" Then
- RmoveComboText()
- LoadProduct(ProductNameTXT.Text)
- ProductAddBTN.Text = "تعديل"
- Else
- RmoveComboText()
- ProductAddBTN.Text = "إضافة"
- End If
- End Sub
- Private Sub NewStore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewStore.Click
- AddNewComboText()
- End Sub
- Public Sub AddNewComboText()
- Dim NewStoreTXT As New ComboBox
- Dim NewMountTXT As New TextBox
- Dim NewUnitsTXT As New ComboBox
- Dim NewStoreLBL As New Label
- Dim NewMountLBL As New Label
- Dim MyLeft As Integer = 0
- Dim MyTop As Integer = 0
- NewStoreTXT.AutoCompleteMode = AutoCompleteMode.SuggestAppend
- NewStoreTXT.AutoCompleteSource = AutoCompleteSource.ListItems
- NewUnitsTXT.AutoCompleteMode = AutoCompleteMode.SuggestAppend
- NewUnitsTXT.AutoCompleteSource = AutoCompleteSource.ListItems
- NewStoreTXT.Width = ProductStoreTXT.Width
- NewMountTXT.Width = ProductMountTXT.Width
- NewUnitsTXT.Width = ProductUnitsTXT.Width
- NewStoreLBL.Width = ProductStoreLBL.Width
- NewMountLBL.Width = ProductMountLBL.Width
- NewStoreLBL.Font = ProductStoreLBL.Font
- NewMountLBL.Font = ProductMountLBL.Font
- NewStoreLBL.Text = ProductStoreLBL.Text
- NewMountLBL.Text = ProductMountLBL.Text
- NewStoreLBL.TextAlign = ProductStoreLBL.TextAlign
- NewMountLBL.TextAlign = ProductMountLBL.TextAlign
- NewStoreTXT.RightToLeft = ProductStoreTXT.RightToLeft
- NewMountTXT.RightToLeft = ProductStoreTXT.RightToLeft
- NewUnitsTXT.RightToLeft = ProductUnitsTXT.RightToLeft
- NewStoreLBL.RightToLeft = ProductStoreLBL.RightToLeft
- NewMountLBL.RightToLeft = ProductStoreLBL.RightToLeft
- NewStoreTXT.Name = "NewStoreTXT" & StoreNumber
- NewMountTXT.Name = "NewMountTXT" & StoreNumber
- NewUnitsTXT.Name = "NewUnitsTXT" & StoreNumber
- NewStoreLBL.Name = "NewStoreLBL" & StoreNumber
- NewMountLBL.Name = "NewMountLBL" & StoreNumber
- If StoreNumber = 0 Then
- MyLeft = ProductStoreTXT.Left
- MyTop = ProductStoreTXT.Top + 52
- Else
- StoreNumber -= 1
- MyLeft = Me.Controls.Item("NewStoreTXT" & StoreNumber).Left
- MyTop = Me.Controls.Item("NewStoreTXT" & StoreNumber).Top + 52
- StoreNumber += 1
- End If
- StoreNumber += 1
- NewStoreTXT.Left = MyLeft
- NewUnitsTXT.Left = MyLeft
- NewMountTXT.Left = MyLeft + NewUnitsTXT.Width + 5
- NewStoreLBL.Left = ProductStoreLBL.Left
- NewMountLBL.Left = NewStoreLBL.Left
- NewStoreTXT.Top = MyTop
- NewMountTXT.Top = MyTop + 27
- NewUnitsTXT.Top = MyTop + 27
- NewStoreLBL.Top = MyTop
- NewMountLBL.Top = MyTop + 27
- LoadStore(NewStoreTXT)
- LoadUnits(NewUnitsTXT)
- NewStoreTXT.Visible = True
- NewUnitsTXT.Visible = True
- NewMountTXT.Visible = True
- NewStoreLBL.Visible = True
- NewMountLBL.Visible = True
- NewStoreTXT.TabIndex = 8 + (StoreNumber * 3)
- NewMountTXT.TabIndex = 9 + (StoreNumber * 3)
- NewUnitsTXT.TabIndex = 10 + (StoreNumber * 3)
- NewStore.Top = MyTop + 52
- Me.Height += 52
- Me.Controls.Add(NewStoreTXT)
- Me.Controls.Add(NewUnitsTXT)
- Me.Controls.Add(NewMountTXT)
- Me.Controls.Add(NewStoreLBL)
- Me.Controls.Add(NewMountLBL)
- End Sub
- Public Sub RmoveComboText()
- Dim Addad As Integer = 0
- For Addad = 0 To StoreNumber
- Me.Controls.Remove(Me.Controls.Item("NewStoreTXT" & Addad))
- Me.Controls.Remove(Me.Controls.Item("NewMountTXT" & Addad))
- Me.Controls.Remove(Me.Controls.Item("NewUnitsTXT" & Addad))
- Me.Controls.Remove(Me.Controls.Item("NewStoreLBL" & Addad))
- Me.Controls.Remove(Me.Controls.Item("NewMountLBL" & Addad))
- Next
- NewStore.Top = ProductUnitsTXT.Top + 27
- Me.Height = 467
- StoreNumber = 0
- End Sub
- Public Sub CleanUpComboText()
- Dim Addad As Integer = 0
- For Addad = 0 To StoreNumber - 1
- If Me.Controls.Item("NewStoreTXT" & Addad).Text = "" Then
- Me.Controls.Remove(Me.Controls.Item("NewStoreTXT" & Addad))
- Me.Controls.Remove(Me.Controls.Item("NewMountTXT" & Addad))
- Me.Controls.Remove(Me.Controls.Item("NewUnitsTXT" & Addad))
- Me.Controls.Remove(Me.Controls.Item("NewStoreLBL" & Addad))
- Me.Controls.Remove(Me.Controls.Item("NewMountLBL" & Addad))
- NewStore.Top -= 52
- Me.Height -= 52
- StoreNumber -= 1
- End If
- Next
- End Sub
- Public Sub CalcInter()
- Dim InterValue As Double = 0
- Dim TaxValue As Double = 0
- TaxValue = Val(Val(ProductPriceTXT.Text) * Val(ProductTax1TXT.Text) / 100) + Val(Val(ProductPriceTXT.Text) * Val(ProductTax2TXT.Text) / 100)
- InterValue = Val(ProductPurchTXT.Text) - Val(ProductPriceTXT.Text) - TaxValue
- InterestLBL.Text = "الربح : " & InterValue & " , قيمة الضرائب : " & TaxValue
- End Sub
- Private Sub ProductPriceTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ProductPriceTXT.KeyDown
- If e.KeyCode = Keys.Enter Then ProductTax1TXT.Select()
- End Sub
- Private Sub ProductPriceTXT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductPriceTXT.TextChanged
- CalcInter()
- End Sub
- Private Sub ProductPurchTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ProductPurchTXT.KeyDown
- If e.KeyCode = Keys.Enter Then ProductStoreTXT.Select()
- End Sub
- Private Sub ProductPurchTXT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductPurchTXT.TextChanged
- CalcInter()
- End Sub
- Private Sub ProductTax1TXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ProductTax1TXT.KeyDown
- If e.KeyCode = Keys.Enter Then ProductTax2TXT.Select()
- End Sub
- Private Sub ProductTax1TXT_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ProductTax1TXT.TextChanged
- CalcInter()
- End Sub
- Private Sub ProductTax2TXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ProductTax2TXT.KeyDown
- If e.KeyCode = Keys.Enter Then ProductPurchTXT.Select()
- End Sub
- Private Sub ProductTax2TXT_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ProductTax2TXT.TextChanged
- CalcInter()
- End Sub
- Private Sub ProductTypeTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ProductTypeTXT.KeyDown
- If e.KeyCode = Keys.Enter Then ProductCodeTXT.Select()
- End Sub
- Private Sub ProductTypeTXT_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductTypeTXT.SelectedIndexChanged
- TestServicesIfActivate()
- End Sub
- Private Sub ProductCatTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ProductCatTXT.KeyDown
- If e.KeyCode = Keys.Enter Then ProductTypeTXT.Select()
- End Sub
- Private Sub ProductCodeTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ProductCodeTXT.KeyDown
- If e.KeyCode = Keys.Enter Then ProductPriceTXT.Select()
- End Sub
- Private Sub ProductStoreTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ProductStoreTXT.KeyDown
- If e.KeyCode = Keys.Enter Then ProductMountTXT.Select()
- End Sub
- Private Sub ProductMountTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ProductMountTXT.KeyDown
- If e.KeyCode = Keys.Enter Then ProductUnitsTXT.Select()
- End Sub
- Private Sub ProductUnitsTXT_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ProductUnitsTXT.KeyDown
- If e.KeyCode = Keys.Enter Then ProductAddBTN.Select()
- End Sub
- Public Sub TestServicesIfActivate()
- LastPriceInformation(0) = Val(ProductPriceTXT.Text)
- LastPriceInformation(1) = Val(ProductTax1TXT.Text)
- LastPriceInformation(2) = Val(ProductTax2TXT.Text)
- If ProductTypeTXT.Text = "خدمات" Then
- ProductPriceTXT.Text = 0
- ProductPriceTXT.Enabled = False
- ProductTax1TXT.Text = 0
- ProductTax1TXT.Enabled = False
- ProductTax2TXT.Text = 0
- ProductTax2TXT.Enabled = False
- ProductPurchLBL.Text = "سعر الخدمة :"
- ProductCodeTXT.Text = "-"
- ProductCodeTXT.Enabled = False
- ProductMountTXT.Text = 0
- ProductMountTXT.Enabled = False
- ProductUnitsTXT.Text = "قطعة"
- ProductUnitsTXT.Enabled = False
- NewStore.Enabled = False
- Else
- 'If LastPriceInformation(0) <> 0 Then
- ProductPriceTXT.Text = LastPriceInformation(0)
- ProductPriceTXT.Enabled = True
- ProductTax1TXT.Text = LastPriceInformation(1)
- ProductTax1TXT.Enabled = True
- ProductTax2TXT.Text = LastPriceInformation(2)
- ProductTax2TXT.Enabled = True
- ProductPurchLBL.Text = "سعر المبيع :"
- ProductCodeTXT.Enabled = True
- ProductMountTXT.Enabled = True
- ProductUnitsTXT.Enabled = True
- NewStore.Enabled = True
- 'Else
- 'ProductPriceTXT.Enabled = True
- 'ProductTax1TXT.Enabled = True
- 'ProductTax2TXT.Enabled = True
- 'End If
- End If
- End Sub
- End Class