Exemplo n.º 1
0
        void Edit()
        {
            try
            {
                string id = dtgvdevice.SelectedCells[0].OwningRow.Cells["ID_DEVICE"].Value.ToString();
                dev          = db.DEVICEs.Find(id);
                dev.NAME     = txtName.Text;
                dev.DATEPLAN = DateTime.Parse(dateTimePicker2.Value.ToString("MM-dd-yyyy"));
                dev.QUANTITY = int.Parse(txtquantity.Text);
                dev.ID_USER  = txtUser.Text;
                dev.ID_GROUP = listGroupDevices1[cbbID_GROUP.SelectedIndex].ID_GROUP;
                dev.ENABLE   = bool.Parse(cbbENABLE.Text);
                task         = TaskType.Update;
                var id_his = Guid.NewGuid().ToString();
                his.ID_HISTORY   = id_his;
                his.ID_DEVICE    = id;
                his.UPDATE_CHECK = dev.DATEPLAN;
                his.QUANTITY     = dev.QUANTITY;
                his.ID_USER      = dev.ID_USER;
                his.STATUS       = (int)task;
                db.HISTORies.Add(his);
                db.SaveChanges();
                Load_Data1();
            }

            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
        }
Exemplo n.º 2
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (dev.ENABLE == false)
         {
             string id = txtId.Text;
             dev = db.DEVICEs.First(p => p.ID_DEVICE == id);
             db.DEVICEs.Remove(dev);
             db.SaveChanges();
             Load_Data1();
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString());
     }
 }