private void btnadd_Click(object sender, EventArgs e) { String name; String add; int tp; String nic; int flag = 0; string item = "V"; try { if (String.IsNullOrEmpty(txtname.Text) || String.IsNullOrEmpty(txtadd.Text) || String.IsNullOrEmpty(txttele.Text) || String.IsNullOrEmpty(txtnic.Text)) { flag = 1; MessageBox.Show("Do not keep any fields empty", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } if (txtname.Text.Any(Char.IsDigit)) { flag = 1; MessageBox.Show("Name cannot contain digits", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } if (item.Contains(txtnic.Text.Last())) { flag = 0; } if (txttele.Text.Length != 10) { flag = 1; MessageBox.Show("Wrong format of Telephone Number", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } if (txtnic.Text.Length != 10) { flag = 1; MessageBox.Show("Wrong NIC number format ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (flag == 0) { name = txtname.Text; add = txtadd.Text; tp = Convert.ToInt32(txttele.Text); nic = txtnic.Text; DBCustomer c = new DBCustomer(); int x = c.setCustomer(name, add, tp, nic, u_id); if (x == 1) { this.Hide(); int no = c.getCus_No(name); Sales_Orders so = new Sales_Orders(); so.Show(); so.setid(u_id, no); } } } catch (Exception) { MessageBox.Show("An error occured please fill all the fields"); } }
private void PlaceOrder_Load(object sender, EventArgs e) { DBCustomer s = new DBCustomer(); SqlDataReader DR = s.getNic(); while (DR.Read()) { comboBox1.Items.Add(DR[0]); } }
private void UpdateCustomer_Load(object sender, EventArgs e) { SqlDataAdapter da; DBCustomer i = new DBCustomer(); da = i.getCustomer(); DataTable dt = new DataTable(); da.Fill(dt); dataGridView1.DataSource = dt; }
private void metroButton2_Click(object sender, EventArgs e) { DBCustomer c = new DBCustomer(); cusno = c.getCusNo(cmbcusnic.SelectedItem.ToString()); DBSales s = new DBSales(); DR = s.getSalesOrder(cusno); while (DR.Read()) { cmbsorder.Items.Add(Convert.ToInt32(DR[0])); } }
private void Sales_Returns_Load(object sender, EventArgs e) { txtdate.Text = System.DateTime.Now.ToString("M/d/yyyy"); DBCustomer sd = new DBCustomer(); DR = sd.getNic(); while (DR.Read()) { cmbcusnic.Items.Add(DR[0]); } }
private void btnok_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex == 0 || comboBox1.Text.Length != 10) { MessageBox.Show("Please select a NIC", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DBCustomer cus = new DBCustomer(); nic = comboBox1.SelectedItem.ToString(); no = cus.getCusNo(nic); Sales_Orders s = new Sales_Orders(); s.Show(); s.setid(u_id, no); this.Hide(); } }
private void mtUpdate_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Do you want to update?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dr.ToString() == "Yes") { if (String.IsNullOrEmpty(txtname.Text) || String.IsNullOrEmpty(txtadd.Text) || String.IsNullOrEmpty(txtnic.Text) || txttele.Text.Length != 10) { MessageBox.Show("Check if all the fields are filled", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { String name = txtname.Text; String add = txtadd.Text; String nic = txtnic.Text; DBCustomer di = new DBCustomer(); int tele = Convert.ToInt32(txttele.Text); int no = di.getCusNo(nic); int line = di.updateCustomer(name, add, nic, tele, u_id, no); if (line == 1) { MessageBox.Show("Data entered successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception) { MessageBox.Show("Error,please try again", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } UpdateCustomer upd = new UpdateCustomer(); this.Hide(); upd.Show(); upd.setid(u_id); }