public int updateCustomer(classCustomers customer) { string query = "UPDATE Customer SET CustomerName = '" + customer.cusName + "', Address = '" + customer.address + "', Contactno='" + customer.cusContact + "', Creditvalue='" + customer.cusCreditValue + "' where CustomerId ='" + customer.cusId + "'"; int result = clsConnection.SendQuery(query); return(result); }
public int insertToCustomers(classCustomers customer) { string query = "insert into customer values ( '" + customer.cusId + "', '" + customer.cusName + "', " + customer.cusContact + ", '" + customer.address + "'," + 0 + "); "; int result = clsConnection.SendQuery(query); return(result); }
private void btnSave_Click(object sender, EventArgs e) { try { if (!Regex.Match(txtCusContact.Text, @"^\d{10}$").Success) { throw new Exception("Enter valid phone number"); } var customer = new classCustomers { cusId = txtCustomerId.Text, cusName = txtCustomerName.Text, cusAddress = txtCustomerAddress.Text, cusContact = Int32.Parse(txtCusContact.Text) }; DialogResult result = MessageBox.Show("Are you sure you want to Submit?", "Submit", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { int insertcustomer = customer.insertToCustomers(customer); foreach (var c in this.Controls) { if (c is TextBox) { ((TextBox)c).Text = String.Empty; } if (c is RichTextBox) { ((RichTextBox)c).Text = String.Empty; } } } else { foreach (var c in this.Controls) { if (c is TextBox) { ((TextBox)c).Text = String.Empty; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnChange_Click(object sender, EventArgs e) { try { if (!Regex.Match(txtCusContact.Text, @"^\d{10}$").Success) { throw new Exception("Enter valid phone number"); } var customer = new classCustomers { cusId = txtCustomerId.Text, cusName = txtCustomerName.Text, cusAddress = txtCustomerAddress.Text, cusContact = Int32.Parse(txtCusContact.Text), cusCreditValue = float.Parse(txtCustomerCredit.Text) }; int updatecustomer = customer.updateCustomer(customer); foreach (var c in this.Controls) { if (c is TextBox) { ((TextBox)c).Text = String.Empty; } if (c is RichTextBox) { ((RichTextBox)c).Text = String.Empty; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ClassPayments() { Customer = new classCustomers(); }