private void viewCustomersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            panelMain.Controls.Clear();
            Find_Customer FindCous = new Find_Customer();

            FindCous.TopLevel = false;
            FindCous.Visible  = true;
            panelMain.Controls.Add(FindCous);
        }
 private void btnFindCustoDeleteItem_Click(object sender, EventArgs e)
 {
     try
     {
         /* if(dgvFindCusto.SelectedRows.Count>0)
          * {
          *   int SelectedIndex = dgvFindCusto.SelectedRows[0].Index;
          *   int cusNo = int.Parse(dgvFindCusto[0, SelectedIndex].Value.ToString());*/
         if (MessageBox.Show("Delete Customer " + dgvFindCusto.CurrentRow.Cells[1].Value.ToString() + " " + dgvFindCusto.CurrentRow.Cells[2].Value.ToString(), "Sharp Creation", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
         {
             cusop.delete(dgvFindCusto.CurrentRow.Cells["Coustomer_No"].Value.ToString());
             MessageBox.Show("Customer removed sucessfully", "Sharp Creation", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         Main.p1.Controls.Clear();
         Find_Customer finCus = new Find_Customer();
         finCus.TopLevel = false;
         finCus.Visible  = true;
         Main.p1.Controls.Add(finCus);
     }
     catch (Exception) { }
 }
        private void btnAddCustoAdd_Click(object sender, EventArgs e)
        {
            ep_fname.SetError(txt_updateCustoFirstName, "");
            ep_lname.SetError(txt_updateLastCustoName, "");
            ep_add1.SetError(txt_updateCustoAddLine1, "");
            ep_add2.SetError(txt_updateCustoAddLine2, "");
            ep_mobil.SetError(txt_updateCustoMobile, "");


            try
            {
                if (txt_updateCustoFirstName.Text != "" && txt_updateLastCustoName.Text != "" && txt_updateCustoMobile.Text != "" && txt_updateCustoAddLine1.Text != "" && txt_updateCustoAddLine2.Text != "")
                {
                    if (reg_names.IsMatch(txt_updateCustoFirstName.Text))
                    {
                        if (reg_names.IsMatch(txt_updateLastCustoName.Text))
                        {
                            if (reg_mobile.IsMatch(txt_updateCustoMobile.Text))
                            {
                                cusEDit.updete(lbl_updatecus_No.Text, txt_updateCustoFirstName.Text, txt_updateLastCustoName.Text, txt_updateCustoBussinessName.Text, txt_updateCustoAddLine1.Text, txt_updateCustoAddLine2.Text, txt_updateCustoCity.Text, txt_updateCustoZipPostCode.Text, txt_updateCustoPhone.Text, txt_updateCustoMobile.Text, txt_updateCustoFax.Text, txt_updateCustoDiscount.Text, txt_updateCustoEmail.Text, txt_updateCustoNotes.Text);
                                if (MessageBox.Show("Customer Updated Successfuly.", "New Customer", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                                {
                                    //-----------------clear all textbox.text-----------------------
                                    Action <Control.ControlCollection> func = null;

                                    func = (controls) =>
                                    {
                                        foreach (Control control in controls)
                                        {
                                            if (control is TextBox)
                                            {
                                                (control as TextBox).Clear();
                                            }
                                            else
                                            {
                                                func(control.Controls);
                                            }
                                        }
                                    };
                                    func(Controls);

                                    this.Close();
                                    Main.p1.Controls.Clear();
                                    Find_Customer findcus = new Find_Customer();
                                    findcus.TopLevel = false;
                                    findcus.Visible  = true;
                                    Main.p1.Controls.Add(findcus);
                                }
                            }
                            else
                            {
                                tp_mob.Show("Enter Correct Mobile Number\nMobile must have 10 Number", txt_updateCustoMobile, 3000);
                            }
                        }
                        else
                        {
                            tp_lnme.Show("Enter Last Name in alphanumeric characters", txt_updateLastCustoName, 3000);
                        }
                    }
                    else
                    {
                        tp_fmne.Show("Enter First Name in alphanumeric characters", txt_updateCustoFirstName, 3000);
                    }
                }
                else
                {
                    if (txt_updateCustoFirstName.Text == "")
                    {
                        ep_fname.SetError(txt_updateCustoFirstName, "Enter customer First name ");
                    }

                    if (txt_updateLastCustoName.Text == "")
                    {
                        ep_lname.SetError(txt_updateLastCustoName, "Enter customer last name ");
                    }

                    if (txt_updateCustoAddLine1.Text == "")
                    {
                        ep_add1.SetError(txt_updateCustoAddLine1, "Enter customer Address line1 ");
                    }

                    if (txt_updateCustoAddLine2.Text == "")
                    {
                        ep_add2.SetError(txt_updateCustoAddLine2, "Enter customer Address line2 ");
                    }

                    if (txt_updateCustoMobile.Text == "")
                    {
                        ep_mobil.SetError(txt_updateCustoMobile, "Enter customer Mobile No ");
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Enter Correct data", "Sharp Creation", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }