private void cbbId_Device_SelectedIndexChanged(object sender, EventArgs e) { if (cbbId_Device.SelectedIndex != -1) { string id = listdevice[cbbId_Device.SelectedIndex].Id; dev = db.DEVICEs.Find(id); txtName.Text = dev.DeviceName; txtName.Enabled = false; } }
private void btnDel_Click(object sender, EventArgs e) { string id = dtgviewdevice.SelectedCells[0].OwningRow.Cells["Id"].Value.ToString(); dev = db.DEVICEs.Find(id); dev.IsUsing = false; var Id_history = Guid.NewGuid().ToString(); his.ID_HISTORY = Id_history; his.ID_DEVICE = dev.Id; his.UPDATE_CHECK = dev.DateMaintenance; his.ID_USER = dev.Creator; his.STATUS = TaskType.Remove.ToString(); his.QUANTITY = dev.Qty; db.HISTORies.Add(his); db.SaveChanges(); Load_Data(); }
private void btnEdit_Click(object sender, EventArgs e) { try { string id = Id; dev = db.DEVICEs.Find(id); dev.DeviceName = txtName.Text; dev.VendorName = txtVendor.Text; dev.IsUsing = checkBox1.Checked; dev.Creator = txt_User_Login.Text; dev.DeviceGroup = listgr[cmbGroup.SelectedIndex].ID_GROUP; dev.Remark = txtRemark.Text; dev.Updatetime = DateTime.Parse(datetimerepair.Value.ToString()); dev.Qty = int.Parse(txtQty.Text); task = TaskType.Update; var Id_history = Guid.NewGuid().ToString(); his.ID_HISTORY = Id_history; his.ID_DEVICE = dev.Id; his.UPDATE_CHECK = dev.DateMaintenance; his.STATUS = TaskType.Update.ToString(); his.NOTE = txtRemark.Text; his.QUANTITY = int.Parse(txtQty.Text); his.UPDATE_CHECK = dev.Updatetime; var user = db.USERs.Where(u => u.ID_USER == txt_User_Login.Text).FirstOrDefault(); if (user != null) { string name = user.NAME; his.ID_USER = name; } db.HISTORies.Add(his); db.SaveChanges(); Close(); } catch (Exception ex) { Console.Write(ex.ToString()); } }