public void FillCustomerNames() { try { DataTable dt = new DataTable(); BLCustomerDetails objBL = new BLCustomerDetails(); dt = objBL.getCustomerNames(); if (dt.Rows.Count > 0) { cbCustomerName.DataSource = dt; cbCustomerName.DisplayMember = "Name"; cbCustomerName.ValueMember = "CustomerId"; } } catch (Exception ex) { //MessageBox.Show(ex.Message.ToString()); MessageBox.Show(ex.Message.ToString()); } }
private void searchCustomer() { try { DataTable dt = new DataTable(); BLCustomerDetails objBL = new BLCustomerDetails(); EntCustomerDetails objent = new EntCustomerDetails(); objent.CustomerId = Convert.ToInt32(cbCustomerName.SelectedValue); objent.Name = cbCustomerName.Text; dt = objBL.searchCustomer(objent); if (dt.Rows.Count > 0) { dataGridView1.DataSource = dt; dataGridView1.Columns["CustomerId"].Visible = false; //dataGridView1.Columns[1].HeaderCell.Value = "Sr.No"; dataGridView1.Refresh(); dataGridView1.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void bindGrid() { try { DataTable dt = new DataTable(); BLCustomerDetails objBL = new BLCustomerDetails(); dt = objBL.BindFullGrid(); if (dt.Rows.Count != 0) { dataGridView1.DataSource = dt; //dataGridView1.Columns[-1].HeaderCell.Value = "Row Number"; dataGridView1.Columns[0].HeaderCell.Value = "Sr.No"; dataGridView1.Columns[0].Visible = false; dataGridView1.ReadOnly = true; dataGridView1.AllowUserToAddRows = false; dataGridView1.Refresh(); dataGridView1.Show(); } else { dataGridView1.DataSource = null; dataGridView1.Hide(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void SaveCutomerDetails() { if (Validate()) { if (btnSave.Text == "Save") { string result = ""; string Output = string.Empty; EntCustomerDetails objentcustomerDetails = new EntCustomerDetails(); objentcustomerDetails.CustomerId = Convert.ToInt32(txtcustomerId.Text); objentcustomerDetails.Name = txtcustomername.Text; objentcustomerDetails.MobileNumber = txtmobileNo.Text; objentcustomerDetails.AlternateMobileNo = txtAlternatemobileNo.Text; objentcustomerDetails.Address = txtAddress.Text; objentcustomerDetails.Reference = txtreference.Text; objentcustomerDetails.Nominee = txtnominee.Text; objentcustomerDetails.CreatedDate = DateTime.Now; objentcustomerDetails.CreatedDate = Convert.ToDateTime(txtdate.Text); if (cknotification.Checked == true) { result = "yes"; } else { result = "No"; } objentcustomerDetails.RequiredSMSnotification = result; objentcustomerDetails.BankName = txtbankName.Text; objentcustomerDetails.BankAccountNo = txtbankAccount.Text; BLCustomerDetails objblcustomerdetails = new BLCustomerDetails(); Output = objblcustomerdetails.SaveCustomer(objentcustomerDetails); if (Output == "This record already exists!") { MessageBox.Show(Output); } else { MessageBox.Show("Customer Added Sucessfully.."); } // ClearFields(); ClearFields(); getCustomerId(); bindGrid(); FillCustomerNames(); } else { string result = ""; string Output = string.Empty; EntCustomerDetails objentcustomerDetails = new EntCustomerDetails(); objentcustomerDetails.CustomerId = Convert.ToInt32(txtcustomerId.Text); objentcustomerDetails.Name = txtcustomername.Text; objentcustomerDetails.MobileNumber = txtmobileNo.Text; objentcustomerDetails.AlternateMobileNo = txtAlternatemobileNo.Text; objentcustomerDetails.Address = txtAddress.Text; objentcustomerDetails.Reference = txtreference.Text; objentcustomerDetails.Nominee = txtnominee.Text; //objentcustomerDetails.CreatedDate = DateTime.Now; objentcustomerDetails.CreatedDate = Convert.ToDateTime(txtdate.Text); if (cknotification.Checked == true) { result = "yes"; } else { result = "No"; } objentcustomerDetails.RequiredSMSnotification = result; objentcustomerDetails.BankName = txtbankName.Text; objentcustomerDetails.BankAccountNo = txtbankAccount.Text; BLCustomerDetails objblcustomerdetails = new BLCustomerDetails(); Output = objblcustomerdetails.UpdateCustomer(objentcustomerDetails); if (Output == "This record already exists!") { MessageBox.Show(Output); } else { MessageBox.Show("Customer Updated Sucessfully!!! "); } btnSave.Text = "Save"; ClearFields(); getCustomerId(); bindGrid(); FillCustomerNames(); } } }
public void getCustomerId() { BLCustomerDetails obblcustomerDetails = new BLCustomerDetails(); DataTable dt = obblcustomerDetails.getCustomerId(); try { for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dt.Columns.Count; j++) { if (string.IsNullOrEmpty(dt.Rows[i][j].ToString())) { int a = 1; txtcustomerId.Text = Convert.ToString(a); } else { txtcustomerId.Text = dt.Rows[0][0].ToString(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }