コード例 #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try {
         entities               ent = new entities();
         supplying_permit       s   = new supplying_permit();
         supplying_permit_items si  = new supplying_permit_items();
         s.supp_permit_id  = int.Parse(comboBox1.Text);
         si.supp_permit_id = int.Parse(comboBox1.Text);
         s.warehouse_id    = int.Parse(comboBox2.Text);
         s.supplier_name   = comboBox3.Text;
         si.item_name      = comboBox4.Text;
         si.prod_date      = dateTimePicker1.Value;
         si.amout          = int.Parse(textBox3.Text);
         si.exp_date       = dateTimePicker2.Value;
         ent.supplying_permit.Add(s);
         ent.supplying_permit_items.Add(si);
         ent.SaveChanges();
         comboBox1.Text = comboBox2.Text = comboBox3.Text = comboBox4.Text = textBox3.Text = string.Empty;
     }
     catch { MessageBox.Show("failed"); }
 }
コード例 #2
0
 private void button4_Click(object sender, EventArgs e)
 {
     try
     {
         supplying_permit s = new supplying_permit();
         int      id        = int.Parse(comboBox1.Text);
         entities ent       = new entities();
         s = (from wa in ent.supplying_permit
              where wa.supp_permit_id == id
              select wa).First();
         supplying_permit_items si = new supplying_permit_items();
         si.supp_permit_id = id;
         si.item_name      = comboBox4.Text;
         si.prod_date      = dateTimePicker1.Value;
         si.amout          = int.Parse(textBox3.Text);
         si.exp_date       = dateTimePicker2.Value;
         ent.supplying_permit_items.Add(si);
         ent.SaveChanges();
         comboBox1.Text = comboBox2.Text = comboBox3.Text = comboBox4.Text = textBox3.Text = string.Empty;
         MessageBox.Show("item added");
     }
     catch { MessageBox.Show("enter a valid data"); }
 }
コード例 #3
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         supplying_permit s = new supplying_permit();
         int      id        = int.Parse(comboBox1.Text);
         entities ent       = new entities();
         s = (from wa in ent.supplying_permit
              where wa.supp_permit_id == id
              select wa).First();
         s.warehouse_id  = int.Parse(comboBox2.Text);
         s.supplier_name = comboBox3.Text;
         supplying_permit_items si = new supplying_permit_items();
         string name = comboBox4.Text;
         si = (from wa in ent.supplying_permit_items
               where wa.supp_permit_id == id && wa.item_name == name
               select wa).First();
         si.prod_date = dateTimePicker1.Value;
         si.amout     = int.Parse(textBox3.Text);
         si.exp_date  = dateTimePicker2.Value;
         ent.SaveChanges();
     }
     catch { MessageBox.Show("enter a valid data"); }
 }