Example #1
0
        /// <summary>
        /// Insert Log
        /// </summary>
        /// <param name="boxId"></param>
        private void InsertLog(string boxId)
        {
            if (!string.IsNullOrEmpty(txtProductionID.Text.Trim()) ||
                !string.IsNullOrEmpty(txtMacAddress.Text.Trim()) ||
                !string.IsNullOrEmpty(txtJudge.Text.Trim()))
            {
                int    lineId       = Program.CurrentUser.LineID;
                int    operationId  = Program.CurrentUser.OperationID;
                string operatorId   = Program.CurrentUser.OperatorCode;
                string productionId = txtProductionID.Text.Trim();

                bool   judge  = radioGroupJudge.EditValue.ToString() == "1";
                string status = null;
                if (radioGroupJudge.EditValue.ToString() == "1")
                {
                    status = "P";
                }
                else
                {
                    status = "F";
                }
                string modelName = null;
                if (!string.IsNullOrEmpty(lblCurentModel.Text))
                {
                    modelName = lblCurentModel.Text;
                }
                else
                {
                    modelName = null;
                }
                string dateCheck = DateTime.Now.ToString("yyyy-MM-dd");
                var    logs      = _oqcService.GetLogsByBoxIdAndDate(boxId, dateCheck).ToList();

                if (operationId == 1)
                {
                    // Nếu Box có dữ liệu của PCB
                    if (logs.Any())
                    {
                        var log = logs.FirstOrDefault(l => l.ProductionID == productionId);
                        // Nếu PCB mới bắn vào chưa có trong Box
                        if (log == null)
                        {
                            try
                            {
                                _iqcService.InsertLogs(productionId, lineId, txtMacAddress.Text, boxId, modelName, "N/T", 1, operatorId, false, "IT", StringHelper.GetInfo(), "tmp");

                                if (!_iqcService.CheckResultExits(productionId, operationId))
                                {
                                    _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);
                                }
                                else
                                {
                                    _iqcService.UpdateResult(productionId, operationId, judge, operatorId);
                                }
                                CreateFileLog(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID);
                                logs = _oqcService.GetLogsByBoxIdAndDate(boxId, dateCheck).ToList();
                                gridControlData.Refresh();
                                gridControlData.DataSource = logs;
                                lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);

                                SetSuccessStatus(true, "PASS", $"Thành công!\nPCB [{txtProductionID.Text}]");
                                ResetControls();
                            }
                            catch (Exception ex)
                            {
                                SetErrorStatus(true, "NG", "Error Insert! \n" + ex.Message);
                                ResetControls();
                            }
                        }
                        // Nếu có rồi thì thống báo lỗi
                        else
                        {
                            SetErrorStatus(true, "NG", $"PCB [{txtProductionID.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
                        {
                            _iqcService.InsertLogs(productionId, lineId, txtMacAddress.Text, boxId, modelName, "N/T", 1, operatorId, false, "IT", StringHelper.GetInfo(), "tmp");

                            if (!_iqcService.CheckResultExits(txtProductionID.Text, operationId))
                            {
                                _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);
                            }
                            else
                            {
                                _iqcService.UpdateResult(productionId, operationId, judge, operatorId);
                            }
                            //CreateFileLog(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID);
                            logs = _oqcService.GetLogsByBoxIdAndDate(boxId, dateCheck).ToList();
                            gridControlData.Refresh();
                            gridControlData.DataSource = logs;
                            lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);

                            SetSuccessStatus(true, "PASS", string.Format("Thêm thành công!\nPCB [{0}]", productionId));
                            ResetControls();
                        }
                        catch (Exception ex)
                        {
                            SetErrorStatus(true, "NG", "Error Insert! \n" + ex.Message);
                            ResetControls();
                        }
                    }
                }
                else if (operationId >= 2)
                {
                    _iqcService.UpdateLogs(productionId, lineId, txtMacAddress.Text, boxId, lblCurentModel.Text, null, operatorId, "tmp");
                    _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);

                    logs = _oqcService.GetLogsByBoxIdAndDate(boxId, dateCheck).ToList();
                    gridControlData.Refresh();
                    gridControlData.DataSource = logs;
                    lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);

                    SetSuccessStatus(true, "PASS", string.Format("Thành công!\nPCB [{0}] vừa được bắn lại lần {1}", productionId, operationId));
                    ResetControls();
                }
            }
            else
            {
                SetErrorStatus(true, "NG", "Vui lòng nhập đủ thông tin!");
                txtProductionID.Focus();
                txtProductionID.SelectAll();
            }
        }
Example #2
0
        /// <summary>
        /// Insert Log
        /// </summary>
        /// <param name="boxId"></param>
        private void InsertLog(string boxId)
        {
            if (!string.IsNullOrEmpty(txtProductionID.Text.Trim()) ||
                !string.IsNullOrEmpty(txtMacAddress.Text.Trim()) ||
                !string.IsNullOrEmpty(txtJudge.Text.Trim()))
            {
                int    lineId      = Program.CurrentUser.LineID;
                int    operationId = Program.CurrentUser.OperationID;
                string operatorId  = Program.CurrentUser.OperatorCode;
                bool   judge       = txtJudge.Text.Trim() == "1";

                if (operationId == 1)
                {
                    var logs = _oqcService.GetLogsByBoxId(boxId).ToList();
                    // Nếu Box có dữ liệu của PCB
                    if (logs.Any())
                    {
                        var log = logs.FirstOrDefault(l => l.ProductionID == txtProductionID.Text);
                        // Nếu PCB mới bắn vào chưa có trong Box
                        if (log == null)
                        {
                            if (!CheckProductionId(txtProductionID.Text, lblCurentModel.Text, lblSerialNo.Text))
                            {
                                SetErrorStatus(true, "NG", $"Error {lblCurentModel.Text} !\nPCB [{txtProductionID.Text}]\nnày khác với các PCB trong Box [{boxId}].\nVui lòng kiểm tra lại!");
                                txtProductionID.SelectAll();
                                Ultils.EditTextErrorNoMessage(txtProductionID);
                                txtJudge.ResetText();
                                txtMacAddress.ResetText();
                                txtBoxID.ResetText();
                            }
                            else
                            {
                                string tmp           = lblQuantityModel.Text.Replace("/", "");
                                int    countPcbInBox = int.Parse(lblCountPCB.Text);
                                int    quantity      = int.Parse(tmp);

                                if (countPcbInBox == quantity)
                                {
                                    SetErrorStatus(true, "OK", "Thùng đã đủ số lượng, vui lòng kiểm tra lại!");
                                    ResetControls();
                                }
                                else
                                {
                                    try
                                    {
                                        _iqcService.InsertLogs(txtProductionID.Text, lineId, txtMacAddress.Text, boxId, null, null, 1, operatorId);

                                        if (!_iqcService.CheckResultExits(txtProductionID.Text, operationId))
                                        {
                                            _iqcService.InsertResult(txtProductionID.Text, operationId, judge, operatorId);
                                        }
                                        else
                                        {
                                            _iqcService.UpdateResult(txtProductionID.Text, operationId, judge, operatorId);
                                        }
                                        var refeshData = _iqcService.GetLogs(boxId).ToList();
                                        gridControlData.Refresh();
                                        gridControlData.DataSource = refeshData;
                                        lblCountPCB.Text           = refeshData.Count.ToString(CultureInfo.InvariantCulture);

                                        SetSuccessStatus(true, "PASS", string.Format("Thêm thành công!\nPCB [{0}]", txtProductionID.Text));
                                        ResetControls();
                                    }
                                    catch (Exception ex)
                                    {
                                        SetErrorStatus(true, "NG", "Error Insert! \n" + ex.Message);
                                        ResetControls();
                                    }
                                }
                            }
                        }
                        // Nếu có rồi thì thống báo lỗi
                        else
                        {
                            SetErrorStatus(true, "NG", $"PCB [{txtProductionID.Text}] này đã có trong Box rồi.\nVui lòng kiểm tra lại");
                            ResetControls();
                            var refeshData = _oqcService.GetLogsByBoxId(boxId);
                            gridControlData.Refresh();
                            gridControlData.DataSource = refeshData;
                        }
                    }
                    // Nếu Box chưa có dữ liệu gì, thực hiện insert
                    else
                    {
                        try
                        {
                            _iqcService.InsertLogs(txtProductionID.Text, lineId, txtMacAddress.Text, boxId, null, null, 1, operatorId);

                            if (!_iqcService.CheckResultExits(txtProductionID.Text, operationId))
                            {
                                _iqcService.InsertResult(txtProductionID.Text, operationId, judge, operatorId);
                            }
                            else
                            {
                                _iqcService.UpdateResult(txtProductionID.Text, operationId, judge, operatorId);
                            }
                            var refeshData = _iqcService.GetLogs(boxId).ToList();
                            gridControlData.Refresh();
                            gridControlData.DataSource = refeshData;
                            lblCountPCB.Text           = refeshData.Count.ToString(CultureInfo.InvariantCulture);

                            SetSuccessStatus(true, "PASS", string.Format("Thêm thành công!\nPCB [{0}]", txtProductionID.Text));
                            ResetControls();
                        }
                        catch (Exception ex)
                        {
                            SetErrorStatus(true, "NG", "Error Insert! \n" + ex.Message);
                            ResetControls();
                        }
                    }
                }
                else if (operationId >= 2)
                {
                    _iqcService.UpdateLogs(txtProductionID.Text, lineId, txtMacAddress.Text, boxId, null, null, 1, operatorId);
                    _iqcService.InsertResult(txtProductionID.Text, operationId, judge, operatorId);

                    var refeshData = _iqcService.GetLogs(boxId).ToList();
                    gridControlData.Refresh();
                    gridControlData.DataSource = refeshData;
                    lblCountPCB.Text           = refeshData.Count.ToString(CultureInfo.InvariantCulture);

                    SetSuccessStatus(true, "PASS", string.Format("Thành công!\nPCB [{0}] vừa được bắn lại lần {1}", txtProductionID.Text, operationId));
                    ResetControls();
                }
            }
            else
            {
                SetErrorStatus(true, "NG", "Vui lòng nhập đủ thông tin!");
                txtProductionID.Focus();
            }
        }
Example #3
0
        /// <summary>
        /// Insert Log
        /// </summary>
        /// <param name="boxId"></param>
        private void InsertLog(string boxId)
        {
            if (!string.IsNullOrEmpty(txtProductID.Text.Trim()) ||
                !string.IsNullOrEmpty(txtBoxID.Text.Trim()))
            {
                int    lineId       = Program.CurrentUser.LineID;
                int    operationId  = Program.CurrentUser.OperationID;
                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 = _oqcService.GetLogsByBoxId(boxId).ToList();
                if (operationId == 1)
                {
                    // 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)
                        {
                            //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);
                            //    txtProductID.ResetText();
                            //}
                            //else
                            //{
                            try
                            {
                                _iqcService.InsertLogs(productionId, lineId, "N/A", boxId, modelID, "N/T", 1, operatorId, false, "IT", StringHelper.GetInfo(), "N/A");

                                if (!_iqcService.CheckResultExits(productionId, operationId))
                                {
                                    _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);
                                }
                                else
                                {
                                    _iqcService.UpdateResult(productionId, operationId, judge, operatorId);
                                }
                                Ultils.CreateFileLog(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                                Ultils.CreateFileLogDirModelName(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                                logs = _oqcService.GetLogsByBoxId(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);
                                //    txtProductID.ResetText();
                                //}
                            }
                            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();
                            }
                            //}
                        }
                        // 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
                        {
                            _iqcService.InsertLogs(productionId, lineId, "N/A", boxId, modelID, "N/T", 1, operatorId, false, "IT", StringHelper.GetInfo(), "N/A");

                            if (!_iqcService.CheckResultExits(txtProductID.Text, operationId))
                            {
                                _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);
                            }
                            else
                            {
                                _iqcService.UpdateResult(productionId, operationId, judge, operatorId);
                            }
                            Ultils.CreateFileLog(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                            Ultils.CreateFileLogDirModelName(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                            logs = _oqcService.GetLogsByBoxId(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 if (operationId >= 2)
                {
                    _iqcService.UpdateLogs(productionId, lineId, "N/A", boxId, modelID, null, operatorId, "N/A");
                    _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);

                    logs = _oqcService.GetLogsByBoxId(boxId).ToList();
                    gridControlData.Refresh();
                    gridControlData.DataSource = logs;
                    lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);

                    SetSuccessStatus("OK", string.Format("Thành công!\nPCB [{0}] vừa được bắn lại lần {1}", productionId, operationId));
                    ResetControls();
                }
            }
            else
            {
                SetErrorStatus("NG", "Vui lòng nhập đủ thông tin!");
                txtProductID.Focus();
                txtProductID.SelectAll();
            }
        }
Example #4
0
        private void txtBoxID_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab)
            {
                if (string.IsNullOrEmpty(txtBoxID.Text))
                {
                    Ultils.TextControlNotNull(txtBoxID, "Box");
                }
                else
                {
                    string strBoxId = txtBoxID.Text;
                    bool   judge    = txtJudge.Text.Trim() == "1";
                    if (strBoxId.Length >= 3)
                    {
                        if (strBoxId.Substring(0, 3).ToUpper() != "F00")
                        {
                            Ultils.EditTextErrorMessage(txtBoxID, "BOX ID phải bắt đầu bằng F00");
                            txtBoxID.SelectAll();
                        }
                        else
                        {
                            var currentBox = _oqcService.CheckBoxIdExits(txtBoxID.Text.Trim());
                            if (currentBox != null)
                            {
                                //var production = _oqcService.GetLogByProductionId(txtProductionID.Text);
                                if (_log.BoxID == txtBoxID.Text.Trim())
                                {
                                    string tmp           = lblQuantityModel.Text.Replace("/", "");
                                    int    countPcbInBox = int.Parse(lblCountPCB.Text);
                                    int    quantity      = int.Parse(tmp);

                                    //if (countPcbInBox == quantity)
                                    //{
                                    //    SetErrorStatus(true, "OK", "Thùng đã được kiểm tra xong. Vui lòng\nkiểm tra thùng khác!");
                                    //    txtProductionID.Focus();
                                    //    ResetControls();
                                    //}
                                    //else
                                    //{
                                    try
                                    {
                                        _oqcService.UpdateOQCCheck(_log, Program.CurrentUser.OperatorCode);
                                        if (txtJudge.Text.Trim() == "0")
                                        {
                                            _iqcService.UpdateResult(_log.ProductionID, Program.CurrentUser.OperationID, judge, Program.CurrentUser.OperatorCode);
                                        }
                                        var logs = _oqcService.GetLogsByBoxId(txtBoxID.Text.Trim()).Where(l => l.QA_Check);
                                        gridControlData.DataSource = logs;
                                        lblCountPCB.Text           = logs.Count().ToString();
                                        SetSuccessStatus(true, "OK", "Thành công!");
                                        ResetControls();
                                    }
                                    catch (Exception ex)
                                    {
                                        SetErrorStatus(true, "NG", $"Error update!\n {ex.Message}");
                                        txtBoxID.SelectAll();
                                        Ultils.EditTextErrorNoMessage(txtBoxID);
                                    }
                                    //}
                                }
                                else
                                {
                                    SetErrorStatus(true, "NG",
                                                   $"PCB [{txtProductionID.Text}] không nằm\ntrong Box: {txtBoxID.Text} này.\n" +
                                                   "Vui lòng kiểm tra lại.");
                                    txtBoxID.SelectAll();
                                    Ultils.EditTextErrorNoMessage(txtBoxID);
                                }
                            }
                            else
                            {
                                SetErrorStatus(true, "NG",
                                               $"Box [{txtBoxID.Text}] không tồn tại trong hệ thống.\n" +
                                               "Vui lòng kiểm tra lại.");
                                txtBoxID.SelectAll();
                                Ultils.EditTextErrorNoMessage(txtBoxID);
                            }
                        }
                    }
                    else
                    {
                        Ultils.EditTextErrorMessage(txtBoxID, "BOX ID không đúng!");
                        txtBoxID.SelectAll();
                    }
                }
            }
        }