private void txtLineID_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { if (string.IsNullOrEmpty(txtLineID.Text)) { Ultils.TextControlNotNull(txtLineID, "Line"); } else { int line = int.Parse(txtLineID.Text.Trim()); if (line > 20) { Ultils.EditTextErrorMessage(txtLineID, "Line error!"); } else { if (txtProcess.Enabled == true) { txtProcess.Focus(); } else { btnLogin.Focus(); } } } } }
private void txtOperatorID_Validating(object sender, CancelEventArgs e) { string operatorCode = txtOperatorID.Text; if (!string.IsNullOrEmpty(operatorCode)) { _operator = _context.Operators.SingleOrDefault(o => o.ID == operatorCode); if (_operator == null) { Ultils.EditTextErrorMessage(txtOperatorID, "Opeator code không tồn tại trong hệ thống!"); } else { txtLineID.Focus(); } } }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtModelName.Text)) { Ultils.EditTextErrorMessage(txtModelName, "Model Name không được bỏ trống!"); } else if (string.IsNullOrEmpty(txtQuantity.Text)) { Ultils.EditTextErrorMessage(txtQuantity, "Quantity không được bỏ trống!"); } else if (string.IsNullOrEmpty(txtSerialNo.Text)) { Ultils.EditTextErrorMessage(txtSerialNo, "Serial No không được bỏ trống!"); } else { var model = new Model() { ModelName = txtModelName.Text, Quantity = int.Parse(txtQuantity.Text), SerialNo = txtSerialNo.Text, }; try { _context.Models.Add(model); _context.SaveChanges(); LoadData(); ResetTextControls(); MessageBox.Show("Insert success!"); } catch (Exception ex) { MessageBox.Show($"Error inresrt!\n {ex.Message}", "Error Insert!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void SearchPCB(string productionId) { splashScreenManager2.ShowWaitForm(); if (string.IsNullOrEmpty(productionId)) { splashScreenManager2.CloseWaitForm(); Ultils.TextControlNotNull(txtSearchPCB, "Nhập vào từ khóa cần tìm!"); txtSearchPCB.SelectAll(); } else { if (comboBoxEditSearchByKey.EditValue.Equals("Production ID")) { var logs = _context.Nichicon.SingleOrDefault(n => n.ProductionID == productionId); var list = new List <Nichicon>(); if (logs != null) { list.Add(logs); gridControlData.DataSource = list; btnDelete.Enabled = true; splashScreenManager2.CloseWaitForm(); } else { splashScreenManager2.CloseWaitForm(); MessageBoxHelper.ShowMessageBoxWaring($"No results width ID:[{productionId}]"); txtSearchPCB.SelectAll(); txtSearchPCB.Focus(); } } else if (comboBoxEditSearchByKey.EditValue.Equals("Box ID")) { string strLength = txtSearchPCB.Text; if (strLength.Length >= 3) { if (strLength.Substring(0, 3).ToUpper() != "F00") { splashScreenManager2.CloseWaitForm(); Ultils.EditTextErrorMessage(txtSearchPCB, "BOX ID phải bắt đầu bằng F00"); txtSearchPCB.SelectAll(); } else { var logs = _context.Nichicon.Where(n => n.BoxID == productionId).ToList(); if (logs.Any()) { gridControlData.DataSource = logs; btnDelete.Enabled = true; splashScreenManager2.CloseWaitForm(); } else { splashScreenManager2.CloseWaitForm(); MessageBoxHelper.ShowMessageBoxWaring($"Không tìm thấy PCB nào trong Box [{productionId}]"); txtSearchPCB.SelectAll(); txtSearchPCB.Focus(); } } } } } }