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 pictureBox1_Click(object sender, EventArgs e)
        {
            this.Hide();
            Sales_Orders s = new Sales_Orders();

            s.Show();
            s.setid(u_id, cus_no);
        }
Example #3
0
        private void mtcancel_Click_1(object sender, EventArgs e)
        {
            /*txtprice.Text = "";
             * txtqty.Text = "";
             * txtstatus.Text = "";
             * txttotqty.Text = "";
             * cmbitemname.SelectedIndex = 0;
             * dataGridView1.CurrentRow.Cells["itemName"].Value = "";
             * dataGridView1.CurrentRow.Cells["itemQty"].Value = "";
             * dataGridView1.CurrentRow.Cells["itemPrice"].Value = ""; */
            this.Hide();
            Sales_Orders so = new Sales_Orders();

            so.setid(u_id, no);
            so.Show();
        }
Example #4
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();
     }
 }