N
no[one]
Guest
here is my code
Private Sub diagnosis2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
table.Columns.Add("ID", Type.GetType("System.String"))
table.Columns.Add("Date", Type.GetType("System.String"))
table.Columns.Add("Tooth Surf No.", Type.GetType("System.String"))
table.Columns.Add("Procedure", Type.GetType("System.String"))
table.Columns.Add("Dentist", Type.GetType("System.String"))
table.Columns.Add(New DataColumn() With {.ColumnName = "Amt. Charged", .DataType = GetType(Single)})
table.Columns.Add(New DataColumn() With {.ColumnName = "Paid", .DataType = GetType(Single)})
table.Columns.Add(New DataColumn() With {.ColumnName = "Bal", .DataType = GetType(Single)})
table.Columns.Add("Next Appointment", Type.GetType("System.String"))
DataGridView1.DataSource = table
DataGridView1.Columns("Amt. Charged").DefaultCellStyle.Format = "#,##0.00"
DataGridView1.Columns("Paid").DefaultCellStyle.Format = "#,##0.00"
DataGridView1.Columns("Bal").DefaultCellStyle.Format = "#,##0.00"
End Sub
Private Sub btnadd_Click(sender As Object, e As EventArgs) Handles btnadd.Click
table.Rows.Add(txtboxid.Text, l1.Text, txtboxno.Text, cbservice.Text, ComboBox1.Text, txtboxprice.Text, txtboxpaid.Text, txtboxbal.Text, txtboxappointment.Text)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim cmd As MySqlCommand
con.Open()
Try
cmd = con.CreateCommand
For i As Integer = 0 To DataGridView1.Rows.Count - 2 Step +1
cmd = New MySqlCommand("INSERT INTO `diagnose`(`lname`,`fname`,`id`,`plan`,`date`, `tooth`, `procedure`, `dentist`,`charged`,`paid`,`bal`, `appointment`) VALUES (@number,' " & txtboxlname.Text & " ',' " & txtboxfname.Text & " ', @id, ' " & rtxtboxplan.Text & " ', @date, @tooth, @pro, @dentist,@charged,@paid ,@bal, @appointment)", con)
cmd.Parameters.Add("@id", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(1).Value.ToString()
cmd.Parameters.Add("@date", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(2).Value.ToString()
cmd.Parameters.Add("@tooth", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(3).Value.ToString()
cmd.Parameters.Add("@pro", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(4).Value.ToString()
cmd.Parameters.Add("@dentist", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(5).Value.ToString()
cmd.Parameters.Add("@charged", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(6).Value.ToString()
cmd.Parameters.Add("@paid", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(7).Value.ToString()
cmd.Parameters.Add("@bal", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(8).Value.ToString()
cmd.Parameters.Add("@appointment", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(9).Value.ToString()
cmd.ExecuteNonQuery()
Next
MessageBox.Show("All Data Inserted")
Call CType(DataGridView1.DataSource, DataTable).Rows.Clear()
load()
con.Close()
Catch ex As Exception
End Try
End Sub
but after saving my datagridview, the decimal in my number is removed
Continue reading...
Private Sub diagnosis2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
table.Columns.Add("ID", Type.GetType("System.String"))
table.Columns.Add("Date", Type.GetType("System.String"))
table.Columns.Add("Tooth Surf No.", Type.GetType("System.String"))
table.Columns.Add("Procedure", Type.GetType("System.String"))
table.Columns.Add("Dentist", Type.GetType("System.String"))
table.Columns.Add(New DataColumn() With {.ColumnName = "Amt. Charged", .DataType = GetType(Single)})
table.Columns.Add(New DataColumn() With {.ColumnName = "Paid", .DataType = GetType(Single)})
table.Columns.Add(New DataColumn() With {.ColumnName = "Bal", .DataType = GetType(Single)})
table.Columns.Add("Next Appointment", Type.GetType("System.String"))
DataGridView1.DataSource = table
DataGridView1.Columns("Amt. Charged").DefaultCellStyle.Format = "#,##0.00"
DataGridView1.Columns("Paid").DefaultCellStyle.Format = "#,##0.00"
DataGridView1.Columns("Bal").DefaultCellStyle.Format = "#,##0.00"
End Sub
Private Sub btnadd_Click(sender As Object, e As EventArgs) Handles btnadd.Click
table.Rows.Add(txtboxid.Text, l1.Text, txtboxno.Text, cbservice.Text, ComboBox1.Text, txtboxprice.Text, txtboxpaid.Text, txtboxbal.Text, txtboxappointment.Text)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim cmd As MySqlCommand
con.Open()
Try
cmd = con.CreateCommand
For i As Integer = 0 To DataGridView1.Rows.Count - 2 Step +1
cmd = New MySqlCommand("INSERT INTO `diagnose`(`lname`,`fname`,`id`,`plan`,`date`, `tooth`, `procedure`, `dentist`,`charged`,`paid`,`bal`, `appointment`) VALUES (@number,' " & txtboxlname.Text & " ',' " & txtboxfname.Text & " ', @id, ' " & rtxtboxplan.Text & " ', @date, @tooth, @pro, @dentist,@charged,@paid ,@bal, @appointment)", con)
cmd.Parameters.Add("@id", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(1).Value.ToString()
cmd.Parameters.Add("@date", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(2).Value.ToString()
cmd.Parameters.Add("@tooth", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(3).Value.ToString()
cmd.Parameters.Add("@pro", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(4).Value.ToString()
cmd.Parameters.Add("@dentist", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(5).Value.ToString()
cmd.Parameters.Add("@charged", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(6).Value.ToString()
cmd.Parameters.Add("@paid", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(7).Value.ToString()
cmd.Parameters.Add("@bal", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(8).Value.ToString()
cmd.Parameters.Add("@appointment", MySqlDbType.VarChar).Value = DataGridView1.Rows(i).Cells(9).Value.ToString()
cmd.ExecuteNonQuery()
Next
MessageBox.Show("All Data Inserted")
Call CType(DataGridView1.DataSource, DataTable).Rows.Clear()
load()
con.Close()
Catch ex As Exception
End Try
End Sub
but after saving my datagridview, the decimal in my number is removed
Continue reading...