private void txtLineID_Validating(object sender, CancelEventArgs e) { if (!string.IsNullOrEmpty(txtLineID.Text)) { int value = 0; if (!int.TryParse(txtLineID.Text, out value)) { dxErrorProvider1.SetError(txtLineID, "Error! Line value faild."); Ultils.EditTextErrorNoMessage(txtLineID); } else { if (value > 20) { dxErrorProvider1.SetError(txtLineID, "Error! Line value faild."); Ultils.EditTextErrorNoMessage(txtLineID); } else { if (txtProcess.Enabled == true) { txtProcess.Focus(); } else { btnLogin.Focus(); } } } } }
private void txtProductionID_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { _dateTimeCheck = DateTime.Now; if (string.IsNullOrEmpty(txtProductID.Text)) { SetErrorStatus("NG", $"Label không được để trống!"); Ultils.EditTextErrorNoMessage(txtProductID); } else { string productionId = txtProductID.Text.Trim(); if (productionId.Length <= 16) { SetErrorStatus("NG", $"Error! Label không đúng định dạng!"); txtProductID.SelectAll(); Ultils.EditTextErrorNoMessage(txtProductID); } else { if (productionId.Contains(lblCurentModel.Text) && productionId.Contains(lblSerialNo.Text)) { InsertLog(txtBoxID.Text.Trim()); } else { SetErrorStatus("NG", $"Sai Label. Vui lòng kiểm tra lại!"); Ultils.EditTextErrorNoMessage(txtProductID); } } } } }
private void txtModelUMC_EditValueChanged(object sender, EventArgs e) { Ultils.SetColorDefaultTextControl(txtModelUMC); string modelName = txtModelUMC.EditValue.ToString(); if (!string.IsNullOrEmpty(modelName)) { var model = _context.Models.SingleOrDefault(m => m.ModelID == modelName); if (model != null) { lblQuantityModel.Visible = true; lblQuantityModel.Text = $"/{model.Quantity}"; tableLayoutPanelModel.Visible = true; lblCurentModel.Text = model.ModelName; lblSerialNo.Text = model.SerialNo; modelID = model.ModelID; modelName = model.ModelName.Trim(); serialNo = model.SerialNo.Trim(); // Enable = true txtBoxID.Enabled = true; checkPASS.Enabled = true; checkNG.Enabled = true; txtProductID.Enabled = true; txtBoxID.Focus(); } else { SetErrorStatus("NG", $"Sai Model. Vui lòng kiểm tra lại!"); Ultils.EditTextErrorNoMessage(txtModelUMC); } } }
private void txtBoxID_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab) { if (string.IsNullOrEmpty(txtBoxID.Text)) { SetErrorStatus("NG", "Box ID không được để trống!"); Ultils.EditTextErrorNoMessage(txtBoxID); } else { string strBoxId = txtBoxID.Text; if (strBoxId.Length >= 3) { if (strBoxId.Substring(0, 3).ToUpper() != "F00") { SetErrorStatus("NG", "BOX ID phải bắt đầu bằng F00!"); Ultils.EditTextErrorNoMessage(txtBoxID); txtBoxID.SelectAll(); } else { EnableBoxIDWidthModel(false); txtProductID.Focus(); } } else { SetErrorStatus("NG", "BOX ID không đúng định đạng!"); Ultils.EditTextErrorNoMessage(txtBoxID); } } } }
private void txtProcess_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { if (string.IsNullOrEmpty(txtProcess.Text)) { dxErrorProvider1.SetError(txtProcess, "Error! Process value required."); Ultils.EditTextErrorNoMessage(txtProcess); } else { btnLogin.PerformClick(); } } }
private void txtModelUMC_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { string modelName = txtModelUMC.Text.Trim(); if (!string.IsNullOrEmpty(modelName)) { _model = _context.Models.SingleOrDefault(m => m.ModelID == txtModelUMC.EditValue.ToString()); if (_model != null) { lblQuantityModel.Visible = true; lblQuantityModel.Text = $"/{_model.Quantity}"; tableLayoutPanelModel.Visible = true; lblCurentModel.Text = _model.ModelName; lblSerialNo.Text = _model.SerialNo; modelID = _model.ModelID; // Enable = true txtBoxID.Enabled = true; checkPASS.Enabled = true; checkNG.Enabled = true; txtProductID.Enabled = true; txtBoxID.Focus(); } else { SetErrorStatus("NG", $"Sai Model. Vui lòng kiểm tra lại!"); Ultils.EditTextErrorNoMessage(txtModelUMC); } } else { SetErrorStatus("NG", $"Vui lòng nhập vào Model UMC trước!"); Ultils.EditTextErrorNoMessage(txtModelUMC); } } }
/// <summary> /// Insert Log /// </summary> /// <param name="boxId"></param> private void InsertLog(string boxId) { if (!string.IsNullOrEmpty(txtProductID.Text.Trim()) || !string.IsNullOrEmpty(txtBoxID.Text.Trim()) || !string.IsNullOrEmpty(txtModelUMC.Text.Trim())) { int lineId = Program.CurrentUser.LineID; string operatorId = Program.CurrentUser.OperatorCode; string productionId = txtProductID.Text.Trim(); string status = null; bool judge = false; if (checkPASS.Checked == true) { status = "P"; judge = true; } if (checkNG.Checked == true) { status = "F"; judge = false; } var logs = _context.Set <Nichicon>().Where(n => n.BoxID == boxId).ToList(); // Nếu Box có dữ liệu của PCB if (logs.Any()) { var log = logs.SingleOrDefault(l => l.ProductionID == productionId); // Nếu PCB mới bắn vào chưa có trong Box if (log == null) { var checkModelInBox = logs.FirstOrDefault(); // Nếu Production ID, có Model giống với Model hiện tại if (productionId.Contains(checkModelInBox.ModelName)) { string tmp = lblQuantityModel.Text.Replace("/", ""); int countPcbInBox = int.Parse(lblCountPCB.Text); int quantity = int.Parse(tmp); if (logs.Count == quantity) { SetErrorStatus("NG", $"Box [{txtBoxID.Text}] đã đủ số lượng. Vui lòng kiểm tra lại!"); Ultils.EditTextErrorNoMessage(txtBoxID); EnableBoxIDWidthModel(true); txtProductID.ResetText(); } else { try { // Insert Add(productionId, lineId, boxId, modelID, txtModelUMC.Text, operatorId, judge); Ultils.CreateFileLog(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck); Ultils.CreateFileLogDirModelName(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck); logs = _context.Set <Nichicon>().Where(n => n.BoxID == boxId).ToList(); gridControlData.Refresh(); gridControlData.DataSource = logs; lblCountPCB.Text = logs.Count.ToString(CultureInfo.InvariantCulture); SetSuccessStatus("OK", $"Thành công!\nPCB [{txtProductID.Text}]"); ResetControls(); if (logs.Count() == quantity) { SetErrorStatus("NG", $"Box [{txtBoxID.Text}] đã đủ số lượng. Vui lòng lấy box mới!"); Ultils.EditTextErrorNoMessage(txtBoxID); EnableBoxIDWidthModel(true); } } catch (Exception ex) { SetErrorStatus("NG", "Model chưa có trong hệ thống!\nVui lòng nhập model này vào, và thử lại. \n" + ex.Message); ResetControls(); } } } else { SetErrorStatus("NG", "Sai Model! Vui lòng kiểm tra và thử lại!"); Ultils.EditTextErrorNoMessage(txtProductID); ResetControls(); logs = _context.Set <Nichicon>().Where(n => n.BoxID == boxId).ToList(); gridControlData.Refresh(); gridControlData.DataSource = logs; lblCountPCB.Text = logs.Count.ToString(CultureInfo.InvariantCulture); } } // Nếu có rồi thì thống báo lỗi else { SetErrorStatus("NG", $"PCB [{txtProductID.Text}] này đã có trong Box rồi.\nVui lòng kiểm tra lại"); ResetControls(); gridControlData.Refresh(); gridControlData.DataSource = logs; lblCountPCB.Text = logs.Count.ToString(CultureInfo.InvariantCulture); } } // Nếu Box chưa có dữ liệu gì, thực hiện insert else { try { // Insert Add(productionId, lineId, boxId, modelID, txtModelUMC.Text, operatorId, judge); Ultils.CreateFileLog(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck); Ultils.CreateFileLogDirModelName(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck); logs = _context.Set <Nichicon>().Where(n => n.BoxID == boxId).ToList(); gridControlData.Refresh(); gridControlData.DataSource = logs; lblCountPCB.Text = logs.Count.ToString(CultureInfo.InvariantCulture); SetSuccessStatus("OK", string.Format("Thêm thành công!\nPCB [{0}]", productionId)); ResetControls(); } catch (Exception ex) { SetErrorStatus("NG", "Error Insert! \n" + ex.Message); ResetControls(); } } } else { SetErrorStatus("NG", "Vui lòng nhập đủ thông tin!"); EnableBoxIDWidthModel(true); txtBoxID.Focus(); } }