Exemplo n.º 1
0
        private void updateData()
        {
            if (textBox1.Text != "")
            {
                Customer c = (from x in cheese.Customers where x.CustomerID.Equals(textBox1.Text) select x).First();
                if (c != null)
                {
                    c.CustomerName = textBox2.Text;
                    if (radioButton1.Checked)
                    {
                        c.CustomerGender = "Male";
                    }
                    else if (radioButton2.Checked)
                    {
                        c.CustomerGender = "Female";
                    }
                    c.CustomerAddress       = textBox3.Text;
                    c.CustomerContactNumber = textBox4.Text;
                    c.CustomerEmail         = textBox5.Text;

                    DetailCustomer dC = new DetailCustomer();
                    dC.CustomerID      = textBox1.Text;
                    dC.LastUpdatedBy   = _MainForm.userID;
                    dC.LastUpdatedDate = DateTime.Now;
                    cheese.DetailCustomers.Add(dC);
                    cheese.SaveChanges();
                    loadData();
                    clear();
                    EnabledStatus(false);
                    ButtonStatus(true);
                    label7.Visible = false;
                    flag           = 0;
                }
            }
        }
Exemplo n.º 2
0
 private void insertData()
 {
     if (textBox2.Text == "")
     {
         label7.Visible = true;
         label7.Text    = "Name Must be Filled";
     }
     else if (radioButton1.Checked == false && radioButton2.Checked == false)
     {
         label7.Visible = true;
         label7.Text    = "Gender Must be Choose";
     }
     else if (textBox3.Text == "")
     {
         label7.Visible = true;
         label7.Text    = "Address Can't be Empty";
     }
     else if (textBox4.Text == "")
     {
         label7.Visible = true;
         label7.Text    = "Contact Number Must be Filled";
     }
     else if (textBox5.Text == "")
     {
         label7.Visible = true;
         label7.Text    = "Email Can Not Be Empty";
     }
     else
     {
         Customer       c  = new Customer();
         DetailCustomer dC = new DetailCustomer();
         c.CustomerID   = textBox1.Text;
         c.CustomerName = textBox2.Text;
         if (radioButton1.Checked)
         {
             c.CustomerGender = "Male";
         }
         else if (radioButton2.Checked)
         {
             c.CustomerGender = "Female";
         }
         c.CustomerAddress       = textBox3.Text;
         c.CustomerContactNumber = textBox4.Text;
         c.CustomerEmail         = textBox5.Text;
         c.RegisterBy            = _MainForm.userID;
         c.RegisterDate          = DateTime.Now;
         dC.CustomerID           = textBox1.Text;
         dC.LastUpdatedBy        = _MainForm.userID;
         dC.LastUpdatedDate      = DateTime.Now;
         cheese.Customers.Add(c);
         cheese.DetailCustomers.Add(dC);
         cheese.SaveChanges();
         loadData();
         clear();
         EnabledStatus(false);
         ButtonStatus(true);
         label7.Visible = false;
         flag           = 0;
     }
 }