AdjustStore.vb
- Public Class AdjustStore
- 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"
- Private Shared AdjustStoreInstance As AdjustStore
- Public Shared Function GetInstance() As AdjustStore
- If (AdjustStoreInstance Is Nothing) Then
- AdjustStoreInstance = New AdjustStore
- End If
- Return AdjustStoreInstance
- End Function
- Private Sub AdjustStore_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- LV.Columns.Add("إسم السلعة \ المنتج")
- LV.Columns.Add("الكمية")
- LV.Columns.Add("التصنيف")
- LV.Columns.Add("سعر المبيع")
- LV.Columns.Add("ربح القطعة")
- LoadStores()
- LoadSelectedStore()
- Refresher.Enabled = True
- End Sub
- Public Sub LoadSelectedStore()
- LV.Items.Clear()
- Dim SName As String = ""
- Dim SAmount As Double = 0
- Dim SCat As String = ""
- Dim SPurch As Double = 0
- Dim SInter As Double = 0
- Dim Addad As Integer = 0
- For Addad = 0 To My.Computer.FileSystem.GetFiles(StoresPath & "\" & CNameTXT.Text).Count - 1
- SName = My.Computer.FileSystem.GetFileInfo(My.Computer.FileSystem.GetFiles(StoresPath & "\" & CNameTXT.Text).Item(Addad)).Name.Replace(".dat", "")
- 'SCat = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\cat.dat", System.Text.Encoding.GetEncoding(0))
- SCat = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\cat.dat", System.Text.Encoding.GetEncoding(0))
- 'SPurch = Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\purch.dat", System.Text.Encoding.GetEncoding(0)))
- SPurch = Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\purch.dat", System.Text.Encoding.GetEncoding(0)))
- '.............................
- Dim MyStoreName As String = CNameTXT.Text
- Dim FName As String = ""
- If MyStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\store.dat", System.Text.Encoding.GetEncoding(0)) Then FName = "mount.dat" : GoTo FinishStoreName
- If Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\stores.dat", System.Text.Encoding.GetEncoding(0))) = 0 Then
- If My.Computer.FileSystem.FileExists(ProductPath & "\" & SName & "\mount0.dat") = True Then
- If MyStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\store0.dat", System.Text.Encoding.GetEncoding(0)) Then FName = "mount0.dat" : GoTo FinishStoreName
- End If
- Else
- Dim SubAddad As Integer = 0
- For SubAddad = 0 To Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\stores.dat", System.Text.Encoding.GetEncoding(0)))
- If MyStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\store" & SubAddad & ".dat", System.Text.Encoding.GetEncoding(0)) Then FName = "mount" & SubAddad & ".dat" : GoTo FinishStoreName
- Next
- End If
- FinishStoreName:
- SAmount = Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\" & FName, System.Text.Encoding.GetEncoding(0)))
- '.............................
- Dim InterValue As Double = 0
- Dim TaxValue As Double = 0
- TaxValue = Val(Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\price.dat", System.Text.Encoding.GetEncoding(0))) * Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\maintax.dat", System.Text.Encoding.GetEncoding(0))) / 100) + Val(Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\price.dat", System.Text.Encoding.GetEncoding(0))) * Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\subtax.dat", System.Text.Encoding.GetEncoding(0))) / 100)
- InterValue = SPurch - Val(Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\price.dat", System.Text.Encoding.GetEncoding(0)))) - (TaxValue)
- SInter = InterValue
- LV.Items.Add(SName)
- LV.Items.Item(LV.Items.Count - 1).SubItems.Add(SAmount)
- LV.Items.Item(LV.Items.Count - 1).SubItems.Add(SCat)
- LV.Items.Item(LV.Items.Count - 1).SubItems.Add(SPurch)
- LV.Items.Item(LV.Items.Count - 1).SubItems.Add(SInter)
- Next
- LV.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
- End Sub
- Public Sub LoadStores()
- CNameTXT.Items.Clear()
- ToStoresTXT.Items.Clear()
- Dim Addad As Integer = 0
- For Addad = 0 To My.Computer.FileSystem.GetDirectories(StoresPath).Count - 1
- Dim SPath As String = My.Computer.FileSystem.GetDirectories(StoresPath).Item(Addad)
- Dim SName As String = My.Computer.FileSystem.GetDirectoryInfo(My.Computer.FileSystem.GetDirectories(StoresPath).Item(Addad)).Name
- CNameTXT.Items.Add(SName)
- ToStoresTXT.Items.Add(SName)
- Next
- CNameTXT.Text = My.Computer.FileSystem.ReadAllText(DataPath & "\defaultstore.dat", System.Text.Encoding.GetEncoding(0))
- ToStoresTXT.Text = My.Computer.FileSystem.ReadAllText(DataPath & "\defaultstore.dat", System.Text.Encoding.GetEncoding(0))
- End Sub
- Private Sub ProductCancleBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseBTN.Click
- ToStoresTXT.Visible = False
- MoveBTN.Visible = False
- StartUp.CloseTabs()
- End Sub
- Private Sub LV_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles LV.DoubleClick
- LoadProduct()
- End Sub
- Public Sub LoadProduct()
- If LV.SelectedItems.Count > 0 Then
- NewProduct.GetInstance.LoadProduct(LV.FocusedItem.Text)
- StartUp.MainPanel.Controls.Clear()
- StartUp.MainPanel.Controls.Add(NewProduct.GetInstance())
- StartUp.AddNewTab(NewProduct.GetInstance.Tag, NewProduct.GetInstance.Name)
- End If
- End Sub
- Private Sub CNameTXT_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CNameTXT.SelectedIndexChanged
- LoadSelectedStore()
- End Sub
- Private Sub RenameStoreBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RenameStoreBTN.Click
- Dim NewName As String = ""
- NewName = InputBox("إسم المخزن الجديد", "إعادة تسمية المخزن", CNameTXT.Text)
- If NewName <> "" And NewName <> CNameTXT.Text Then
- RenameStore(CNameTXT.Text, NewName)
- End If
- End Sub
- Public Sub RenameStore(ByVal OldName As String, ByVal NewName As String)
- My.Computer.FileSystem.RenameDirectory(StoresPath & "\" & OldName, NewName)
- Dim Addad As Integer = 0
- For Addad = 0 To LV.Items.Count - 1
- Dim MyStoreName As String = CNameTXT.Text
- Dim SName As String = LV.Items.Item(Addad).Text
- Dim FName As String = ""
- If MyStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\store.dat", System.Text.Encoding.GetEncoding(0)) Then FName = "store.dat" : GoTo FinishStoreName
- If Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\stores.dat", System.Text.Encoding.GetEncoding(0))) = 0 Then
- If My.Computer.FileSystem.FileExists(ProductPath & "\" & SName & "\store0.dat") = True Then
- If MyStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\store0.dat", System.Text.Encoding.GetEncoding(0)) Then FName = "store0.dat" : GoTo FinishStoreName
- End If
- Else
- Dim SubAddad As Integer = 0
- For SubAddad = 0 To Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\stores.dat", System.Text.Encoding.GetEncoding(0)))
- If MyStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & SName & "\store" & SubAddad & ".dat", System.Text.Encoding.GetEncoding(0)) Then FName = "store" & SubAddad & ".dat" : GoTo FinishStoreName
- Next
- End If
- FinishStoreName:
- My.Computer.FileSystem.WriteAllText(ProductPath & "\" & SName & "\" & FName, NewName, False, System.Text.Encoding.GetEncoding(0))
- Next
- LoadStores()
- CNameTXT.SelectedItem = NewName
- LoadSelectedStore()
- End Sub
- Private Sub LV_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles LV.GotFocus
- ToStoresTXT.Visible = True
- MoveBTN.Visible = True
- MoveLBL.Visible = True
- End Sub
- Private Sub MoveBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoveBTN.Click
- Dim PName As String = ""
- Dim PAmount As Double = 0
- Dim SStoreName As String = CNameTXT.Text
- Dim SName As String = ""
- Dim SAName As String = ""
- Dim SUName As String = ""
- Dim TStoreName As String = ToStoresTXT.Text
- Dim TName As String = ""
- Dim TAName As String = ""
- Dim TUName As String = ""
- Dim TAddad As Integer = 0
- If CNameTXT.Text <> ToStoresTXT.Text Then
- PName = LV.FocusedItem.Text
- PAmount = Val(InputBox("الكمية التي ترغب بنقلها :", "نقل " & PName & " من مخزن " & CNameTXT.Text & " - إلى مخزن " & ToStoresTXT.Text, "0"))
- If PAmount <> 0 And PAmount <> Nothing And PAmount <= Val(LV.FocusedItem.SubItems(1).Text) Then
- 'Special Target Store Product :
- If SStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\store.dat", System.Text.Encoding.GetEncoding(0)) Then
- SName = "store.dat"
- SAName = "mount.dat"
- SUName = "unit.dat"
- GoTo FirsStepFinished
- End If
- 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 SStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\store0.dat", System.Text.Encoding.GetEncoding(0)) Then
- SName = "store0.dat"
- SAName = "mount0.dat"
- SUName = "unit0.dat"
- GoTo FirsStepFinished
- End If
- 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 SStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\store" & SubAddad & ".dat", System.Text.Encoding.GetEncoding(0)) Then
- SName = "store" & SubAddad & ".dat"
- SAName = "mount" & SubAddad & ".dat"
- SUName = "unit" & SubAddad & ".dat"
- GoTo FirsStepFinished
- End If
- Next
- End If
- ';;;;;;;;;;;;;;;;;;;;;;;;;;
- 'Source Store not contains product
- ';;;;;;;;;;;;;;;;;;;;;;;;;;
- FirsStepFinished:
- 'Special Target Store Product :
- If TStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\store.dat", System.Text.Encoding.GetEncoding(0)) Then
- TName = "store.dat"
- TAName = "mount.dat"
- TUName = "unit.dat"
- TAddad = 0
- GoTo Finish
- End If
- 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 TStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\store0.dat", System.Text.Encoding.GetEncoding(0)) Then
- TName = "store0.dat"
- TAName = "mount0.dat"
- TUName = "unit0.dat"
- TAddad = 1
- GoTo Finish
- End If
- 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 TStoreName = My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\store" & SubAddad & ".dat", System.Text.Encoding.GetEncoding(0)) Then
- TName = "store" & SubAddad & ".dat"
- TAName = "mount" & SubAddad & ".dat"
- TUName = "unit" & SubAddad & ".dat"
- TAddad = Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\stores.dat", System.Text.Encoding.GetEncoding(0))) + 1
- GoTo Finish
- End If
- Next
- End If
- ';;;;;;;;;;;;;;;;;;;;;;;;;;
- 'Target Store not contains product
- ';;;;;;;;;;;;;;;;;;;;;;;;;;
- My.Computer.FileSystem.WriteAllText(StoresPath & "\" & TStoreName & "\" & PName & ".dat", "0", False, System.Text.Encoding.GetEncoding(0))
- TName = "store" & TAddad & ".dat"
- TAName = "mount" & TAddad & ".dat"
- My.Computer.FileSystem.WriteAllText(ProductPath & "\" & PName & "\stores.dat", TAddad, False, System.Text.Encoding.GetEncoding(0))
- My.Computer.FileSystem.WriteAllText(ProductPath & "\" & PName & "\store" & TAddad & ".dat", TStoreName, 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", Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\" & SUName, System.Text.Encoding.GetEncoding(0))), False, System.Text.Encoding.GetEncoding(0))
- Finish:
- Dim LastAmount As Double = 0
- LastAmount = Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\" & SAName, System.Text.Encoding.GetEncoding(0)))
- LastAmount = LastAmount - PAmount
- My.Computer.FileSystem.WriteAllText(ProductPath & "\" & PName & "\" & SAName, LastAmount, False, System.Text.Encoding.GetEncoding(0))
- LastAmount = Val(My.Computer.FileSystem.ReadAllText(ProductPath & "\" & PName & "\" & TAName, System.Text.Encoding.GetEncoding(0)))
- LastAmount = LastAmount + PAmount
- My.Computer.FileSystem.WriteAllText(ProductPath & "\" & PName & "\" & TAName, LastAmount, False, System.Text.Encoding.GetEncoding(0))
- ToStoresTXT.Visible = False
- MoveBTN.Visible = False
- MoveLBL.Visible = False
- LoadSelectedStore()
- End If
- End If
- End Sub
- Private Sub Refresher_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Refresher.Tick
- LoadSelectedStore()
- End Sub
- End Class