Imports System.Data.SqlClient Imports System.Data Imports System.Drawing Imports System.Web.UI.WebControls Public Class Services Private colCase As DataGridViewComboBoxColumn Private cproductTOTAL As DataGridViewTextBoxColumn Protected Sub Services_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'Servicesdb.Services' table. You can move, or remove it, as needed. Me.ServicesTableAdapter.Fill(Me.Servicesdb.Services) 'TODO: This line of code loads data into the 'Productsdb.Products' table. You can move, or remove it, as needed. Me.ProductsTableAdapter.Fill(Me.Productsdb.Products) colCase = New DataGridViewComboBoxColumn cproductTOTAL = New DataGridViewTextBoxColumn Dim oldValue As String = "" Dim con As New SqlConnection("Data Source=DESKTOP-9U3RT7R\SQLEXPRESS;Initial Catalog=Salon;Integrated Security=True") Dim view As New DataView Dim dataset As New DataSet Dim com As New SqlCommand 'Dim chk As New DataGridViewCheckBoxColumn() 'chk.HeaderText = "Select Service" 'chk.Name = "chk" 'Me.ServicesDataGridView.Columns.Add(chk) End Sub Private Sub servicecancelbtn_Click(sender As System.Object, e As System.EventArgs) Handles servicecancelbtn.Click Me.Dispose() ClientDetails.Show() End Sub Private cboCase As DataGridViewComboBoxEditingControl = Nothing Private txtproductTOTAL As DataGridViewTextBoxCell = Nothing Private Sub ServicesDataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles ServicesDataGridView.EditingControlShowing 'If the current cell is of the type "ComboBox" If TypeOf (e.Control) Is DataGridViewComboBoxEditingControl Then 'Cast the current cell to the temporary control cboCase = DirectCast(e.Control, DataGridViewComboBoxEditingControl) 'Cast the other cell to the other temporary control txtproductTOTAL = DirectCast(ServicesDataGridView.CurrentRow.Cells(productTOTAL.Name), DataGridViewTextBoxCell) If cboCase IsNot Nothing Then 'Add an EventHandler to the first temporary control AddHandler cboCase.SelectedIndexChanged, AddressOf cboCase_SelectedIndexChanged End If End If End Sub Private Sub cboCase_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Dim con As New SqlConnection("Data Source=DESKTOP-9U3RT7R\SQLEXPRESS;Initial Catalog=Salon;Integrated Security=True") Dim view As New DataView Dim dataset As New DataSet Dim com As New SqlCommand Dim StateTable As New DataTable StateTable.Clear() Dim sqlCmd As New SqlCommand("select DISTINCT productTOTAL from Products where productNAME='" & cboCase.Text & "'", con) 'con.Close() Dim result As String Try con.Open() result = sqlCmd.ExecuteScalar() If result IsNot Nothing Then txtproductTOTAL.Value = result.ToString() 'MessageBox.Show(txtState.Text) End If Catch ex As SqlException MessageBox.Show(ex.Message) Finally con.Close() End Try End Sub Private Sub ServicesDataGridView_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles ServicesDataGridView.CellEndEdit If cboCase IsNot Nothing Then RemoveHandler cboCase.SelectedIndexChanged, AddressOf cboCase_SelectedIndexChanged cboCase = Nothing End If txtproductTOTAL = Nothing End Sub Private Sub ServicesDataGridView_CellLeave(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles ServicesDataGridView.CellLeave Try Dim iCell1 As Integer Dim icell2 As Integer Dim icellResult As Integer iCell1 = ServicesDataGridView.CurrentRow.Cells(3).Value icell2 = ServicesDataGridView.CurrentRow.Cells(4).Value icellResult = iCell1 + icell2 ServicesDataGridView.CurrentRow.Cells(5).Value = icellResult Catch ex As Exception MessageBox.Show(ex.ToString) End Try 'Make sure the selectionMode is set to cellSelect. Once user leaves the cell 3 it will get the calculated values in it. End Sub Protected Sub showservicesbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles showservicesbtn.Click Try For Each row As GridViewRow In ServicesDataGridView.SelectedRows Dim sum As Integer = Integer.Parse(row.Cells(5).ToString()) 'Dim chkbox As CheckBox 'chkbox = TryCast(row.FindControl("chk"), CheckBox) 'If chkbox.Checked Then ' sum = sum + row.Cells(5).Text.ToString() 'End If ' If serviceselect.Selected Then sum = sum + Integer.Parse(row.Cells(5).ToString()) lblmsg.Text = sum.ToString() Next Catch ex As Exception MsgBox(ex.Message) End Try Try Dim Data As String = "EyeBrows" For Each row As GridViewRow In ServicesDataGridView.SelectedRows If row.RowType = DataControlRowType.DataRow Then Dim chkRow As CheckBox = TryCast(row.Cells(6).FindControl("chk"), CheckBox) If chkRow.Checked Then Dim serviceNAME As String = row.Cells(1).Text Data = Convert.ToString((Data & serviceNAME) + " , ") + "<br>" End If End If Next lblservices.Text = Data Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub serviceokbtn_Click(sender As System.Object, e As System.EventArgs) Handles serviceokbtn.Click ClientDetails.txtserviceID.Text = Me.lblservices.Text ClientDetails.txtappointmentTOTAL.Text = Me.lblmsg.Text ClientDetails.Show() Me.Close() End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)