예제 #1
0
 private void insertData()
 {
     if (textBox2.Text == "")
     {
         label10.Visible = true;
         label10.Text    = "Milk Variation Must be Filled";
     }
     else
     {
         Milk m = new Milk();
         m.MilkID        = textBox1.Text;
         m.MilkName      = textBox2.Text;
         m.MilkLifeTime  = dateTimePicker1.Value;
         m.InputBy       = _MainForm.userID;
         m.MilkInputDate = DateTime.Now;
         cheese.Milk.Add(m);
         cheese.SaveChanges();
         loadData();
         clear();
         EnabledStatus(false);
         ButtonStatus(true);
         label10.Visible = false;
         flag            = 0;
     }
 }
예제 #2
0
 private void updateData()
 {
     if (textBox1.Text != "")
     {
         Milk m = (from x in cheese.Milk where x.MilkID.Equals(textBox1.Text) select x).First();
         if (m != null)
         {
             m.MilkName     = textBox2.Text;
             m.MilkLifeTime = dateTimePicker1.Value;
             cheese.SaveChanges();
             loadData();
             clear();
             EnabledStatus(false);
             ButtonStatus(true);
             label10.Visible = false;
             flag            = 0;
         }
     }
 }
예제 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                DialogResult dr = MessageBox.Show("Delete " + textBox1.Text, "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    Milk deleteM = (from x in cheese.Milk
                                    where x.MilkID.Equals(textBox1.Text)
                                    select x).First();
                    cheese.Milk.Remove(deleteM);
                    cheese.SaveChanges();
                    loadData();
                    clear();
                    textBox1.Text = "";
                }
            }
            flag = 0;
        }