private string GetDeviceInfo(devices_tb device) { string info = string.Empty; info += device.device_name + "\n"; info += device.device_barcode + "\n"; info += device.device_status + "\n"; info += device.respon + "\n"; info += device.lab_name + "\n"; info += device.exp_name + "\n"; info += device.exp_num; return(info); }
private void btnRemoveDevice_Click(object sender, EventArgs e) { try { devices_tb selectedDevice = (devices_tb)lstExperimentDevices.SelectedItem; //selectedDevice.lab_name = lab; selectedDevice.exp_name = "بدون تجربة"; selectedDevice.exp_num = 0; db.SaveChanges(); FillListBoxes(); ChechButtonsStatus(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public frmDevice(devices_tb currentDevice)// : base() { InitializeComponent(); this.currentDevice = currentDevice; }
private void saveToolStripButton_Click(object sender, EventArgs e) { string error = string.Empty; if (txtDeviceName.Text == string.Empty) { error += "إدخل اسم الجهاز\n"; } if (cmbLab.SelectedItem == null) { error += "اختر المعمل\n"; } if (cmbExperiment.SelectedItem == null) { error += "اختر التجربة\n"; } if (cmbStatus.SelectedItem == null) { error += "اختر حالة الجهاز\n"; } if (error != string.Empty) { MessageBox.Show(error, "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { try { if (CurrentStatus == Status.New) { GenerateBarcode(); var device = new devices_tb() { device_name = txtDeviceName.Text, device_barcode = Convert.ToDecimal(txtBarcode.Text), device_status = cmbStatus.Text, lab_name = cmbLab.Text, exp_name = cmbExperiment.Text, exp_num = Convert.ToInt32(cmbExperimentNum.SelectedItem == null ? 0 : Convert.ToInt32(cmbExperimentNum.Text)), respon = cmbEmployee.Text, description = txtDescription.Text }; db.devices_tb.Add(device); db.SaveChanges(); MessageBox.Show("تم الحفظ", "تم", MessageBoxButtons.OK, MessageBoxIcon.Information); //ClearControls(); ControlStatus(false); ToolStripButtonStatus(Status.Save); } if (CurrentStatus == Status.Edit) { var selectedItemBarcode = Convert.ToDecimal(txtBarcode.Text); var device = db.devices_tb.FirstOrDefault(u => u.device_barcode == selectedItemBarcode); var oldRespon = device.respon; // for report printing var oldStatus = device.device_status; // for report printing device.device_name = txtDeviceName.Text; device.device_barcode = Convert.ToDecimal(txtBarcode.Text); device.device_status = cmbStatus.Text; device.lab_name = cmbLab.Text; device.exp_name = cmbExperiment.Text; device.exp_num = Convert.ToInt32(cmbExperimentNum.SelectedItem == null ? 0 : Convert.ToInt32(cmbExperimentNum.Text)); device.respon = cmbEmployee.Text; device.description = txtDescription.Text; db.SaveChanges(); MessageBox.Show("تم التعديل", "تم", MessageBoxButtons.OK, MessageBoxIcon.Information); if (oldRespon != cmbEmployee.Text) { DialogResult dialogResult2 = MessageBox.Show("لقد تم تغيير صاحب العهدة هل تريد صباعة التقرير", "رسالة تأكيد", MessageBoxButtons.YesNo); if (dialogResult2 == DialogResult.Yes) { Reports.frmTransferCustodyReport frmTransferCustodyReport = new Reports.frmTransferCustodyReport(); frmTransferCustodyReport.employeeFrom = oldRespon; frmTransferCustodyReport.devicesBarcodes = device.device_barcode.ToString(); frmTransferCustodyReport.ShowDialog(); } } if (oldStatus != "مكهن" && device.device_status == "مكهن") { DialogResult dialogResult2 = MessageBox.Show("لقد تم تكهين الجهاز هل تريد صباعة التقرير", "رسالة تأكيد", MessageBoxButtons.YesNo); if (dialogResult2 == DialogResult.Yes) { Reports.frmTakhinReport frmTakhinReport = new Reports.frmTakhinReport(); frmTakhinReport.barcodes = device.device_barcode.ToString(); frmTakhinReport.ShowDialog(); } } //ClearControls(); ControlStatus(false); ToolStripButtonStatus(Status.Save); Search(); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }