/// <summary> /// Add PCB into Box /// </summary> /// <param name="boxid"></param> private void AddPcbToBox(string boxid) { gridControlData.DataSource = null; if (!string.IsNullOrEmpty(txtAddPCB.Text)) { if (_iqcService.CheckPcbExitsOnBoxOrShipCurrent(txtAddPCB.Text.Trim(), _shippings)) { var ship = _iqcService.GetShippingById(txtAddPCB.Text.Trim()); if (ship == null) { var shipping = new Shipping() { ID = Guid.NewGuid(), Operator = txtOperatorCode.Text, Model = gridLookUpEditModelID.Text, WorkingOder = txtWorkingOrder.Text, Quantity = 1, BoxID = boxid, ProductID = txtAddPCB.Text, PO_NO = txtPO.Text, MacAddress = txtAddPCB.Text, DateCheck = DateTime.Now, }; _shippings.Add(shipping); gridControlData.DataSource = _shippings; lblCountPCB.Text = _shippings.Count.ToString(CultureInfo.InvariantCulture); lblRemains.Text = (int.Parse(lblRemains.Text) - 1).ToString(CultureInfo.InvariantCulture); txtAddPCB.Text = string.Empty; if (_shippings.Count == _currentModel.Quantity) { gridControlData.DataSource = _shippings; InsertOrUpdatePo(gridLookUpEditModelID.EditValue.ToString(), gridLookUpEditModelID.Text, txtPO.Text); splashScreenManager2.ShowWaitForm(); foreach (var log in _shippings) { _iqcService.InsertShipping(txtOperatorCode.Text, gridLookUpEditModelID.EditValue.ToString(), txtWorkingOrder.Text, 1, txtPO.Text, txtBoxID.Text, log.ProductID, log.MacAddress); } _iqcService.UpdateRemainsForPo(_currentPo.PO_NO, _currentPo.ModelID, int.Parse(lblRemains.Text)); splashScreenManager2.CloseWaitForm(); EnableTextControls(true); VisibleControlAddPcb(false); txtBoxID.ResetText(); txtBoxID.Focus(); lblCountPCB.Text = @"0"; gridControlData.DataSource = null; _shippings = new List <Shipping>(); } } else { gridControlData.Refresh(); gridControlData.DataSource = _shippings; MessageBoxHelper.ShowMessageBoxError($"PCB {txtAddPCB.Text} đã được xuất trước đó.\n" + $"Box: {ship.BoxID}\n" + $"Ngày xuất: {ship.DateCheck}"); txtAddPCB.SelectAll(); } } else { gridControlData.Refresh(); gridControlData.DataSource = _shippings; MessageBoxHelper.ShowMessageBoxError($"PCB {txtAddPCB.Text} đã được nhập trong Box rồi. Vui lòng kiểm tra lại!"); txtAddPCB.SelectAll(); } } }
/// <summary> /// Add PCB into Box /// </summary> /// <param name="boxid"></param> private void AddPcbToBox(string boxid) { splashScreenLoadData.ShowWaitForm(); gridControlData.DataSource = null; if (!string.IsNullOrEmpty(txtAddPCB.Text)) { if (_iqcService.CheckPcbExitsOnBoxOrShipCurrent(txtAddPCB.Text, _shippings)) { var shippings = _iqcService.GetShippingById(txtAddPCB.Text.Trim()); if (shippings == null) { var shipping = new Shipping() { ID = Guid.NewGuid(), Operator = txtOperatorCode.Text, Model = gridLookUpEditModelID.EditValue.ToString(), WorkingOder = txtWorkingOrder.Text, Quantity = 1, BoxID = boxid, ProductID = txtAddPCB.Text, MacAddress = txtAddPCB.Text, DateCheck = DateTime.Now, }; if (_currentPo.QuantityRemain <= 0) { MessageBox.Show(@"Không thể nhập thêm cho PO này. Remain = 0\nVui lòng lưu lại dữ liệu!", @"Error Remains!", MessageBoxButtons.OK, MessageBoxIcon.Error); ResetControls(); } else { _shippings.Add(shipping); gridControlData.DataSource = _shippings; lblCountPCB.Text = _shippings.Count.ToString(CultureInfo.InvariantCulture); lblRemains.Text = (int.Parse(lblRemains.Text) - 1).ToString(CultureInfo.InvariantCulture); EnabledButonSave(true); splashScreenLoadData.CloseWaitForm(); txtAddPCB.Text = string.Empty; } } else { gridControlData.Refresh(); gridControlData.DataSource = _shippings; splashScreenLoadData.CloseWaitForm(); MessageBoxHelper.ShowMessageBoxError($"PCB {txtAddPCB.Text} đã được xuất trước đó.\n" + $"Box: {shippings.BoxID}\nN" + $"Ngày xuất: {shippings.DateCheck}"); txtAddPCB.SelectAll(); } } else { gridControlData.Refresh(); gridControlData.DataSource = _shippings; splashScreenLoadData.CloseWaitForm(); MessageBoxHelper.ShowMessageBoxError($"PCB {txtAddPCB.Text} đã được nhập trong Box rồi. Vui lòng kiểm tra lại!"); txtAddPCB.SelectAll(); } } }