تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] مساعدة في الشرح + التطوير ان امكن
#2
الكود يتكون من اربعة جزئيات

الجزء الاول حفظ تاريخ الرصيد المجموع

كود :
Dim con As New OleDb.OleDbConnection(My.Settings.POSConnectionString)
          con.Open()
          Dim sql As String = "Insert into Recipts (ReciptDate,ReciptTotal) Values(:0,:1)"
          Dim cmd As New OleDb.OleDbCommand
          cmd.Parameters.AddWithValue(":0", Date.Now)
          cmd.Parameters.AddWithValue(":1", TextBox4.Text)
          With cmd
              .Connection = con
              .CommandText = sql
          End With
          cmd.ExecuteNonQuery()
          cmd.Dispose()
الجزء الثاني لجلب اكبر قيمة من حقل ReceiptID واستخدام هذه القيمة في رقم رصيد جديد

كود :
Dim cmd1 As New OleDb.OleDbCommand
          sql = "Select max(ReciptID) as MAXID from Recipts"
          With cmd1
              .CommandText = sql
              .Connection = con
          End With
          Dim ReciptID As Long = cmd1.ExecuteScalar
          cmd1.Dispose()

الجزء الثالث لحفظ تفاصيل الرصيد والتفاصيل هنا هو عدد غير محدود من الصفوف الموجودة في الــ DataGridView
كود :
Dim i As Integer
          For i = 0 To DataGridView2.Rows.Count - 1
              Dim Barcode As String = DataGridView2.Rows(i).Cells(0).Value
              Dim BuyPrice As String = DataGridView2.Rows(i).Cells(2).Value
              Dim SellPrice As String = DataGridView2.Rows(i).Cells(3).Value
              Dim ItemCount As Integer = DataGridView2.Rows(i).Cells(4).Value
              Dim cmd2 As New OleDb.OleDbCommand
              sql = "Insert into ReciptDetails values(:0,:1,:2,:3,:4)"
              With cmd2
                  .CommandText = sql
                  .Connection = con
              End With
              cmd2.Parameters.AddWithValue(":0", ReciptID)
              cmd2.Parameters.AddWithValue(":1", Barcode)
              cmd2.Parameters.AddWithValue(":2", ItemCount)
              cmd2.Parameters.AddWithValue(":3", BuyPrice)
              cmd2.Parameters.AddWithValue(":4", SellPrice)
              cmd2.ExecuteNonQuery()
              cmd2.Dispose()
          Next
          con.Close()
          con.Dispose()

الجزء الرابع لطباعة الرصيد 
كود :
If Not IsNothing(TextBox6.Text) Then
              ReciptImage = DrawRecipt(DataGridView2.Rows, ReciptID, Format(Now.Date, "dd-mm-yyyy"), TextBox4.Text, TextBox5.Text, TextBox8.Text, TextBox7.Text)
              If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                  PrintDoc.PrinterSettings = PrintDialog1.PrinterSettings
                  PrintDoc.Print()
                  DataGridView2.Rows.Clear()
                  TextBox4.Clear()
              End If
          ElseIf PictureBox1.Image Is Nothing Then
              MsgBox("Can't Print receipt please check the settings", MsgBoxStyle.Critical)
          Else
              MsgBox("You did not setup the printer", MsgBoxStyle.Exclamation)
          End If

اخي هذا شرح حسب فهمي المتواضع.
الرد }}}
تم الشكر بواسطة: بادئ


الردود في هذا الموضوع
RE: مساعدة في الشرح + التطوير ان امكن - بواسطة Adrees - 09-09-16, 02:26 PM


التنقل السريع :


يقوم بقرائة الموضوع: