/// <summary> /// Register No Set /// </summary> private void RegNoSet() { if (CustomMessageBox.Question("Do you want register this stock-out item?") == DialogResult.No) { return; } #region ADD NEW NO PLAN ITEM string processCD = "NP" + DateTime.Now.ToString("yyyyMMdd-HHmmss"); pts_noplan noplanData = new pts_noplan() { noplan_cd = processCD, destination_cd = cmbDestination.SelectedValue.ToString(), item_cd = txtItemCode.Text, noplan_qty = double.Parse(txtStockOutQty.Text), noplan_usercd = txtUserCode.Text, noplan_date = dtpStockOutDate.Value }; noplanData.AddItem(noplanData); listNoplan.Add(noplanData); #endregion UpdateGridProcess(0); listOut[0].ExportCSV(listOut); listStock[0].UpdateMultiItem(listStock); listStockOut[0].AddMultiItem(listStockOut); CustomMessageBox.Notice("Register process " + processCD + " successful!"); }
private void btnDeletebox_Click(object sender, EventArgs e) { try { if (dgvMain.SelectedRows.Count <= 0) { return; } if (IsBoxMode) { if (CustomMessageBox.Question("Are you sure delete this box?" + Environment.NewLine + "Bạn có muốn xóa hộp dữ liệu này?") == DialogResult.No) { return; } tbl_part_box boxData = dgvMain.SelectedRows[0].DataBoundItem as tbl_part_box; int n = boxData.Delete(boxData.part_box_id); CustomMessageBox.Notice("Deleted box " + txtBoxID.Text + " !" + Environment.NewLine + "Đã xóa hộp " + txtBoxID.Text + " !"); } else { if (CustomMessageBox.Question("Are you sure delete this inspect?" + Environment.NewLine + "Bạn có muốn xóa hạng mục này?") == DialogResult.No) { return; } } } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
private void dgvStockDetail_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (isEditData) { if (CustomMessageBox.Question("This item is edited but not update. Do you want cancel it?") == DialogResult.No) { return; } isEditData = false; } itemData.listItems.Clear(); olditemData = itemData.GetItem(dgvStockDetail.Rows[e.RowIndex].Cells["item_cd"].Value.ToString()); //Get old stock data and show it in fields oldStockData = dgvStockDetail.Rows[e.RowIndex].DataBoundItem as pts_stock; txtItemCD.Text = oldStockData.item_cd; txtInvoice.Text = oldStockData.invoice; txtOrderNo.Text = oldStockData.order_no; txtPackingCD.Text = oldStockData.packing_cd; txtPackingQty.Text = oldStockData.packing_qty.ToString(); txtStockInQty.Text = oldStockData.stockin_qty.ToString(); txtSupplierCD.Text = oldStockData.supplier_cd; txtInCharge.Text = oldStockData.stockin_user_cd; dtpFromDate.Value = oldStockData.stockin_date; dtpToDate.Value = oldStockData.stockin_date; itemData.listItems.Add(olditemData); btnUpdate.Enabled = true; btnDelete.Enabled = true; UpdateGrid(); }
private void btnRegister_Click(object sender, EventArgs e) { try { isSet = false; listOut.Clear(); listPlan.Clear(); listPrint.Clear(); listStock.Clear(); listNoplan.Clear(); listStockOut.Clear(); if (cmbIssue.SelectedValue.ToString() == "30" && string.IsNullOrEmpty(txtComment.Text)) { CustomMessageBox.Error("Please write comment when scrap item"); return; } if (cmbIssue.SelectedValue.ToString() == "20") { OpenSet(dgvMainStockOut.SelectedCells[0].RowIndex); } else { if (CustomMessageBox.Question("Do you want stock-out this item?") == DialogResult.No) { return; } CreateListNoSet(); } } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
private void btnLogOut_Click(object sender, EventArgs e) { if (CustomMessageBox.Question("Are you sure to log-out?") == DialogResult.Yes) { m_login_password mlog = new m_login_password(); UserData.isOnline = mlog.LogIO(UserData.usercode, false); } }
private void FormCommon_FormClosing(object sender, FormClosingEventArgs e) { if (UserData.isOnline) { if (CustomMessageBox.Question("Are you want to close?") == DialogResult.No) { e.Cancel = true; } } }
private void SubForm_FormClosing(object sender, FormClosingEventArgs e) { if (btnOK.Visible) { if (CustomMessageBox.Question("You are in processing!" + Environment.NewLine + "Are you sure exit?") == DialogResult.No) { e.Cancel = true; return; } } }
private void btnDelete_Click(object sender, EventArgs e) { if (dgvNewMeasure.SelectedRows.Count <= 0) { return; } if (CustomMessageBox.Question("Do you want delete this item?" + Environment.NewLine + "Bạn có muốn xóa con hàng này?") == DialogResult.No) { return; } listNewData.RemoveAt(dgvNewMeasure.SelectedRows[0].Index); btnRefresh.PerformClick(); }
private void btnDeleteBox_Click(object sender, EventArgs e) { try { if (CustomMessageBox.Question("Are you sure delete this box?" + Environment.NewLine + "Bạn có đồng ý xóa hộp dữ liệu này?") == DialogResult.No) { return; } tbl_part_box boxData = new tbl_part_box(); int n = boxData.Delete(boxID); CustomMessageBox.Notice("Deleted box " + txtBoxID.Text + " !" + Environment.NewLine + "Đã xóa hộp " + txtBoxID.Text + " !"); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
private void btnAddBox_Click(object sender, EventArgs e) { try { if (!CheckFields()) { return; } string boxCD = txtPartNumber.Text + "#" + txtInvoice.Text + "#" + dtpDate.Value.ToString("yyyyMMdd"); //BoxDataFrom boxfrm = new BoxDataFrom(new tbl_part_box //{ // invoice = txtInvoice.Text, // model_cd = txtModel.Text, // part_box_cd = boxCD, // part_box_date = dtpDate.Value, // part_name = txtPartName.Text, // part_number = txtPartNumber.Text, // vender_cd = txtVender.Text, // purpose_cmt = txtPurpose.Text //}); //boxfrm.ShowDialog(); if (CustomMessageBox.Question("Do you want register this box?" + Environment.NewLine + "Bạn có muốn đăng ký dữ liệu hiện tại?") == DialogResult.No) { return; } tbl_part_box boxData = new tbl_part_box() { part_box_cd = boxCD, model_cd = txtModel.Text, invoice = txtInvoice.Text, part_number = txtPartNumber.Text, part_name = txtPartName.Text, part_box_date = dtpDate.Value, vender_cd = txtVender.Text, purpose_cmt = txtPurpose.Text, part_box_lot = txtLot.Text, part_box_qty = int.Parse(txtQty.Text) }; boxData.Add(boxData); CustomMessageBox.Notice("Add box " + boxCD + " successful!" + Environment.NewLine + "Thêm hộp " + boxCD + " thành công!"); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
private void btnRegister_Click(object sender, EventArgs e) { try { if (CustomMessageBox.Question("Are you sure register this list?" + Environment.NewLine + "Bạn có muốn đăng ký danh sách này?") == DialogResult.No) { return; } for (int i = 0; i < dgvInspection.Rows.Count; i++) { //Register item into stock try { if (stockItem.AddItem(dgvInspection.Rows[i].DataBoundItem as pts_stock) > 0) { listStockItem.Remove(dgvInspection.Rows[i].DataBoundItem as pts_stock); i--; } } catch (Exception ex) { CustomMessageBox.Error(ex.Message); dgvInspection.Rows[i].DefaultCellStyle.BackColor = Color.Red; continue; } //Export new item stock-in to csv for register PREMAC if (listInputPremac.Count > 0) { premacData.ExportCSV(GroupByPremac()); } } CustomMessageBox.Notice("Register Successful!" + Environment.NewLine + "Đăng ký hoàn tất!"); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } if (listInputPremac.Count > 0) { itemData.ListStockInUpdateValue(GroupByPremac()); } listInputPremac.Clear(); UpdateInspectionGrid(); txtBarcode.Focus(); }
/// <summary> /// Click button OK for login /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(txtUsername.Text)) { loginpass = loginpass.CheckLogIn(txtUsername.Text, txtpass.Text); if (loginpass.is_online) { if (CustomMessageBox.Question("This user is online." + Environment.NewLine + "Are you want re-login?") == DialogResult.No) { return; } } UserData.isOnline = loginpass.LogIO(txtUsername.Text, true); mesuser = mesuser.GetUser(loginpass.user_cd); UserData.onTime = 0; timerOnTimeSet.Enabled = true; UserData.dept = mesuser.dept_cd; UserData.usercode = mesuser.user_cd; UserData.username = mesuser.user_name; UserData.position = mesuser.user_position_cd; UserData.logintime = loginpass.last_login_time; UserData.role_permision = userrole.GetListRole(loginpass.user_cd); //Show main form MainForm main = new MainForm(); this.Hide(); txtpass.Clear(); main.ShowDialog(); loginpass.LogIO(txtUsername.Text, false); this.Show(); this.Focus(); } else { CustomMessageBox.Notice("Please fill user code!"); txtUsername.Focus(); } } catch (Exception ex) { CustomMessageBox.Error(ex.Message); txtpass.Clear(); } }
private void RegSet() { try { if (CustomMessageBox.Question("Do you want register this set items?") == DialogResult.No) { return; } string plancode = txtSetOrderNum.Text + "-" + dtpStockOutDate.Value.ToString("yyMMdd"); pts_plan planData = new pts_plan(); planData = new pts_plan { plan_cd = plancode, destination_cd = cmbDestination.SelectedValue.ToString(), model_cd = txtSetHiItem.Text, set_number = txtSetOrderNum.Text, plan_date = dtpSetOrderDate.Value, plan_usercd = txtSetUserCD.Text, plan_qty = double.Parse(txtSetOrderQty.Text), delivery_date = dtpStockOutDate.Value, comment = txtComment.Text }; try { planData.Search(planData); if (planData.listPlan.Count <= 0) { planData.Add(planData); } } catch { planData.Add(planData); } listPlan.Add(planData); listOut[0].ExportCSV(listOut); listStock[0].UpdateMultiItem(listStock); listStockOut[0].AddMultiItem(listStockOut); CustomMessageBox.Notice("Register process " + txtSetOrderNum.Text + " successful!"); UpdateGridProcess(1); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (CustomMessageBox.Question("Do you want delete this item?") == DialogResult.No) { return; } DeleteStock(); ClearFields(); UpdateGrid(false); btnUpdate.Enabled = false; btnDelete.Enabled = false; } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
private void btnRegister_Click(object sender, EventArgs e) { if (CustomMessageBox.Question("Do you want register this box?" + Environment.NewLine + "Bạn có muốn đăng ký dữ liệu hiện tại?") == DialogResult.No) { return; } tbl_part_box boxData = new tbl_part_box() { part_box_cd = txtBoxID.Text, model_cd = txtModel.Text, invoice = txtInvoice.Text, part_number = txtPartNumber.Text, part_name = txtPartName.Text, part_box_date = DateTime.Parse(txtDate.Text), vender_cd = txtVender.Text, purpose_cmt = txtPurpose.Text, part_box_lot = txtLot.Text, part_box_qty = current }; boxData.Add(boxData); }
private void btnNoPlanRegister_Click(object sender, EventArgs e) { try { #region CHECK INFO BEFORE ADD ITEM //Check item empty if (string.IsNullOrEmpty(txtNoPlanItemCD.Text)) { CustomMessageBox.Notice("Item can't empty! Please check and scan barcode again!"); return; } //Check issue code empty if (string.IsNullOrEmpty(cmbNoPlanIssueCD.Text)) { errorProvider.SetError(cmbNoPlanIssueCD, "Please choose issue code!"); return; } //Check destination empty if (string.IsNullOrEmpty(cmbNoPlanDestinationCD.Text)) { errorProvider.SetError(cmbNoPlanDestinationCD, "Please choose destination!"); return; } //Check user code empty if (string.IsNullOrEmpty(txtNoPlanUserCD.Text)) { errorProvider.SetError(txtNoPlanUserCD, "Please fill user code!"); return; } //Check stock-in-hand qty if (double.Parse(txtNoPlanWHQty.Text) == 0) { CustomMessageBox.Notice("Don't have item in stock. Please check and try again!"); return; } //Check stock-out qty if (string.IsNullOrEmpty(txtNoPlanStockOutQty.Text) || double.Parse(txtNoPlanStockOutQty.Text) == 0) { CustomMessageBox.Notice("Please fill stock-out qty!"); return; } //When issue code is 30 then required fill comment if (cmbNoPlanIssueCD.SelectedValue.ToString() == "30" && string.IsNullOrEmpty(txtNoPlanComment.Text)) { CustomMessageBox.Notice("Please fill comment when Scrap Item!"); return; } double stockOutQty = double.Parse(txtNoPlanStockOutQty.Text); //If stock out qty > packing qty then alert if (stockOutQty > double.Parse(txtNoPlanWHQty.Text)) { //if (CustomMessageBox.Warring("Stock-out qty is over than stock-in-hand qty!" + Environment.NewLine + "Are you sure to continue?") == DialogResult.No) CustomMessageBox.Notice("Stock-out qty is over than stock-in-hand qty! Please set another!"); return; } if (CustomMessageBox.Question("Are you sure add this stock-out item?") == DialogResult.No) { return; } #endregion double temp; string processcd = string.Empty; if (txtNoPlanSetNumber.ReadOnly) { #region ADD NEW NO-PLAN processcd = "NP" + DateTime.Now.ToString("yyyyMMdd-HHmmss"); //Add noplan item into list listNoPlan.Add(new pts_noplan { noplan_cd = processcd, destination_cd = cmbNoPlanDestinationCD.SelectedValue.ToString(), item_cd = txtNoPlanItemCD.Text, noplan_qty = stockOutQty, noplan_usercd = txtNoPlanUserCD.Text, noplan_date = dtpNoPlanStockOutDate.Value, }); #endregion //Update grid in inspection tab UpdateProcessGrid(0); //Check all packing in dgv foreach (DataGridViewRow dr in dgvNoPlan.Rows) { //Get packing stockOutQty & packing code stockData = dr.DataBoundItem as pts_stock; //If packing is empty then skip it if (!cbSign.Checked && stockData.packing_qty <= 0) { continue; } //Get item info itemData = itemData.GetItem(stockData.item_cd); //Get supplier supplierData = supplierData.GetSupplier(new pts_supplier { supplier_cd = stockData.supplier_cd }); #region ADD STOCK-OUT ITEM //If stock-out qty > packing qty then stock-out next pack if (stockOutQty > stockData.packing_qty) { temp = stockData.packing_qty; stockOutQty = stockOutQty - stockData.packing_qty; } else //When stock-out qty < pack qty then get a number = stock-out qty { temp = stockOutQty; stockOutQty = 0; } //Add stock-out item into a list listStockOut.Add(new pts_stockout_log { packing_cd = stockData.packing_cd, process_cd = processcd, issue_cd = (int)cmbNoPlanIssueCD.SelectedValue, stockout_date = dtpNoPlanStockOutDate.Value, stockout_user_cd = txtNoPlanUserCD.Text, stockout_qty = temp, comment = txtNoPlanComment.Text, remark = "N", }); #region ADD LIST LABEL STOCK-OUT AND LIST ITEM FOR CSV //Add new label stock-out printData.ListPrintItem.Add(new PrintItem { Item_Number = txtNoPlanItemCD.Text, Item_Name = itemData.item_name, SupplierName = supplierData.supplier_name, Invoice = txtNoPlanInvoice.Text, Delivery_Date = dtpNoPlanStockOutDate.Value, Delivery_Qty = temp, SupplierCD = supplierData.supplier_cd, //OrderNo = stockData.order_no, isRec = false, Label_Qty = 1 }); //Add Output item outData.listOutputItem.Add(new OutputItem { issue_cd = (int)cmbNoPlanIssueCD.SelectedValue, destination_cd = cmbNoPlanDestinationCD.SelectedValue.ToString(), item_number = txtNoPlanItemCD.Text, //item_name = itemData.item_name, //supplier_cd = supplierData.supplier_cd, //supplier_name = supplierData.supplier_name, //supplier_invoice = txtNoPlanInvoice.Text, //order_number = stockData.order_no, delivery_date = dtpNoPlanStockOutDate.Value, delivery_qty = temp, incharge = txtNoPlanUserCD.Text, }); #endregion #endregion #region CALCULATOR, ADD LIST STOCK ITEM AND ADD LIST LABEL STOCK-ON-HAND //Calculator pack qty in stock stockData.packing_qty = stockData.packing_qty - temp; listStock.Add(stockData); //Add new label stock-in when it not empty if (stockData.packing_qty > 0) { printData.ListPrintItem.Add(new PrintItem { Item_Number = txtNoPlanItemCD.Text, Item_Name = itemData.item_name, SupplierName = supplierData.supplier_name, Invoice = txtNoPlanInvoice.Text, Delivery_Date = stockData.stockin_date, Delivery_Qty = stockData.packing_qty, SupplierCD = supplierData.supplier_cd, //OrderNo = stockData.order_no, isRec = true, Label_Qty = 1 }); } #endregion //If get enough stock-out qty then break if (stockOutQty == 0) { break; } } btnNoPlanInspection.Visible = true; if (CustomMessageBox.Question("Successful!. Do you want go to Inspection Tab to see it?") == DialogResult.Yes) { tc_Main.SelectedTab = tab_Inspection; } } else { #region ADD NEW PLAN listPlan.Clear(); processcd = "P" + txtNoPlanSetNumber.Text; listPlan.Add(new pts_plan { plan_cd = processcd, model_cd = txtNoPlanItemCD.Text, set_number = txtNoPlanSetNumber.Text, destination_cd = cmbNoPlanDestinationCD.SelectedValue.ToString(), plan_qty = stockOutQty, plan_usercd = txtNoPlanUserCD.Text, plan_date = dtpNoPlanStockOutDate.Value, delivery_date = dtpNoPlanStockOutDate.Value.AddDays(7), comment = txtNoPlanComment.Text }); #endregion //Update grid in inspection tab UpdateProcessGrid(1); txtNoPlanItemCD.Clear(); tc_Main.SelectedTab = tab_Plan; } } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
private void btnPlanReg_Click(object sender, EventArgs e) { foreach (DataGridViewRow dr in dgvPlan.Rows) { if ((double)dr.Cells["packing_qty"].Value <= 0 || dr.Cells["stockout_qty"].Value == null) { continue; } #region ADD STOCK-OUT ITEM //Add stock-out item into a list listStockOut.Add(new pts_stockout_log { packing_cd = dr.Cells["packing_cd"].Value.ToString(), process_cd = listPlan[0].plan_cd, issue_cd = (int)cmbNoPlanIssueCD.SelectedValue, stockout_date = dtpNoPlanStockOutDate.Value, stockout_user_cd = txtNoPlanUserCD.Text, stockout_qty = (double)dr.Cells["stockout_qty"].Value, comment = txtNoPlanComment.Text, remark = "N", }); #region ADD LIST LABEL STOCK-OUT AND LIST ITEM FOR CSV //Add new label stock-out printData.ListPrintItem.Add(new PrintItem { Item_Number = dr.Cells["item_cd"].Value.ToString(), Item_Name = itemData.GetItem(dr.Cells["item_cd"].Value.ToString()).item_name, SupplierName = supplierData.GetSupplier(new pts_supplier { supplier_cd = dr.Cells["supplier_cd"].Value.ToString() }).supplier_name, Invoice = dr.Cells["invoice"].Value.ToString(), Delivery_Date = dtpNoPlanStockOutDate.Value, Delivery_Qty = (double)dr.Cells["stockout_qty"].Value, SupplierCD = dr.Cells["supplier_cd"].Value.ToString(), //OrderNo = stockData.order_no, isRec = false, Label_Qty = 1 }); //Add Output item outData.listOutputItem.Add(new OutputItem { issue_cd = (int)cmbNoPlanIssueCD.SelectedValue, destination_cd = cmbNoPlanDestinationCD.SelectedValue.ToString(), item_number = dr.Cells["item_cd"].Value.ToString(), //item_name = itemData.item_name, //supplier_cd = supplierData.supplier_cd, //supplier_name = supplierData.supplier_name, //supplier_invoice = txtNoPlanInvoice.Text, //order_number = stockData.order_no, delivery_date = dtpNoPlanStockOutDate.Value, delivery_qty = (double)dr.Cells["stockout_qty"].Value, incharge = txtNoPlanUserCD.Text, }); #endregion #endregion #region CALCULATOR, ADD LIST STOCK ITEM AND ADD LIST LABEL STOCK-ON-HAND //Calculator pack qty in stock double oddnum = (double)dr.Cells["packing_qty"].Value - (double)dr.Cells["stockout_qty"].Value; //listStock.Add(stockData); //Add new label stock-in when it not empty if (oddnum > 0) { printData.ListPrintItem.Add(new PrintItem { Item_Number = dr.Cells["item_cd"].Value.ToString(), Item_Name = itemData.GetItem(dr.Cells["item_cd"].Value.ToString()).item_name, SupplierName = supplierData.GetSupplier(new pts_supplier { supplier_cd = dr.Cells["supplier_cd"].Value.ToString() }).supplier_name, Invoice = dr.Cells["invoice"].Value.ToString(), Delivery_Date = (DateTime)dr.Cells["stockin_date"].Value, Delivery_Qty = oddnum, SupplierCD = dr.Cells["supplier_cd"].Value.ToString(), //OrderNo = stockData.order_no, isRec = true, Label_Qty = 1 }); } #endregion } btnNoPlanInspection.Visible = true; if (CustomMessageBox.Question("Successful!. Do you want go to Inspection Tab to see it?") == DialogResult.Yes) { tc_Main.SelectedTab = tab_Inspection; } }
/// <summary> /// Add new stock item into temp list /// </summary> private void AddNewItem() { try { int n = 0; int temp = 0; string invoice = "None"; string remark = string.Empty; string suppliercd = string.Empty; string[] barcode = txtBarcode.Text.Split(';'); txtSupplierCD.Clear(); txtSupplierName.Clear(); //Label of PREMAC 6-4-9 have more 2 fields if (barcode.Length > 7) { if (!string.IsNullOrEmpty(barcode[6])) { suppliercd = barcode[6]; } if (!string.IsNullOrEmpty(barcode[7])) { remark = barcode[7]; } } try { itemData.GetItem(barcode[0]); } catch { CustomMessageBox.Error("This item is not exisits! Please check and try again!"); return; } #region CHECK SUPPLIER & NOTICE FOR USER errorProvider.SetError(txtSupplierCD, null); txtSupplierName.Text = barcode[2]; try { //If don't have supplier code then search with supplier name and return supplier code if (string.IsNullOrEmpty(suppliercd)) { supplierItem = supplierItem.GetSupplier(new pts_supplier { supplier_id = 0, supplier_name = txtSupplierName.Text }); txtSupplierCD.Text = supplierItem.supplier_cd; } else { txtSupplierCD.Text = suppliercd; //Searh with supplier code supplierItem = supplierItem.GetSupplier(new pts_supplier { supplier_id = 0, supplier_cd = txtSupplierCD.Text }); } } catch (Exception ex) { //If supplier is not exist, create a supplier with simple info errorProvider.SetError(txtSupplierCD, "This supplier is not exist!" + Environment.NewLine + "Please fill supplier code and press F2 for add new supplier (" + ex.Message + ")"); return; } #endregion #region CHECK INVOICE AND CREATE PACKING CODE try { //Search item in stock with invoice number if (stockItem.SearchItem(new pts_stock { item_cd = barcode[0], invoice = barcode[3] })) { double totalStockIn = (from x in stockItem.listStockItems where x.item_cd == barcode[0] select x.stockin_qty).Sum(); double totalPacking = (from x in stockItem.listStockItems where x.item_cd == barcode[0] select x.packing_qty).Sum(); //If this item is exist, notice user string mess = "Item code: " + barcode[0] + " and Invoice: " + barcode[3] + "is exist!" + Environment.NewLine; mess += "Total stock-in: " + totalStockIn + Environment.NewLine + "Total packing: " + totalPacking + Environment.NewLine; mess += "Are you sure add new packing with this Invoice?"; if (CustomMessageBox.Question(mess) == DialogResult.No) { return; } else { //Get max number packing of this Invoice in database foreach (pts_stock item in stockItem.listStockItems) { if (!string.IsNullOrEmpty(item.invoice)) { temp = int.Parse(item.packing_cd.Substring(item.invoice.Length + 1)); } else { temp = int.Parse(item.packing_cd.Substring(5)); } if (temp > n) { n = temp; } } } } } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } //Create new number of packing with Invoice number foreach (pts_stock item in listStockItem) { if (item.invoice == barcode[3]) { if (!string.IsNullOrEmpty(item.invoice)) { temp = int.Parse(item.packing_cd.Substring(item.invoice.Length + 1)); } else { temp = int.Parse(item.packing_cd.Substring(5)); } if (temp > n) { n = temp; } } } n++; if (!string.IsNullOrEmpty(barcode[3].Trim())) { invoice = barcode[3]; } string packingcd = invoice + "-" + n.ToString("00"); #endregion //Add new barcode item into list stock item listStockItem.Add(new pts_stock { item_cd = barcode[0], supplier_cd = txtSupplierCD.Text, invoice = barcode[3], stockin_date = DateTime.Parse(barcode[4]), stockin_qty = double.Parse(barcode[5]), stockin_user_cd = UserData.usercode, //order_no = orderno, packing_cd = packingcd, packing_qty = double.Parse(barcode[5]), registration_user_cd = UserData.usercode, }); if (remark != "P") { listInputPremac.Add(new pre_649 { item_number = barcode[0], item_name = barcode[1], supplier_cd = txtSupplierCD.Text, supplier_name = txtSupplierName.Text, supplier_invoice = barcode[3], delivery_date = DateTime.Parse(barcode[4]), delivery_qty = double.Parse(barcode[5]), incharge = UserData.usercode, //order_number = orderno, }); } UpdateInspectionGrid(); } catch (IndexOutOfRangeException) { CustomMessageBox.Error("Wrong format barcode!" + Environment.NewLine + "Please check barcode and try again!"); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
/// <summary> /// Add new stock item into temp list /// </summary> private void AddNewItem(PrintItem lbItem, int labelQty) { try { int n = 0; int temp = 0; string invoice = "None"; //string remark = string.Empty; //string suppliercd = string.Empty; txtSupplierCD.Clear(); txtSupplierName.Clear(); try { itemData.GetItem(lbItem.Item_Number); } catch { CustomMessageBox.Error("This item is not exisits! Please check and try again!" + Environment.NewLine + "Nguyên liệu này không tồn tại!"); return; } #region CHECK SUPPLIER & NOTICE FOR USER errorProvider.SetError(txtSupplierCD, null); txtSupplierName.Text = lbItem.SupplierName; try { //If don't have supplier code then search with supplier name and return supplier code if (string.IsNullOrEmpty(lbItem.SupplierCD)) { supplierItem = supplierItem.GetSupplier(new pts_supplier { supplier_id = 0, supplier_name = txtSupplierName.Text }); txtSupplierCD.Text = supplierItem.supplier_cd; } else { txtSupplierCD.Text = lbItem.SupplierCD; //Searh with supplier code supplierItem = supplierItem.GetSupplier(new pts_supplier { supplier_id = 0, supplier_cd = txtSupplierCD.Text }); } } catch (Exception ex) { //If supplier is not exist, create a supplier with simple info errorProvider.SetError(txtSupplierCD, "This supplier is not exist!" + Environment.NewLine + "Please fill supplier code and press F2 for add new supplier (" + ex.Message + ")" + Environment.NewLine + "NSX này không tồn tại! Vui lòng điền mã NSX và nhấn F2 để thêm mới NSX"); return; } #endregion #region CHECK INVOICE EXIST try { //Search item in stock with invoice number if (stockItem.SearchItem(new pts_stock { item_cd = lbItem.Item_Number, invoice = lbItem.Invoice })) { double totalStockIn = (from x in stockItem.listStockItems where x.item_cd == lbItem.Item_Number select x.stockin_qty).Sum(); double totalPacking = (from x in stockItem.listStockItems where x.item_cd == lbItem.Item_Number select x.packing_qty).Sum(); //If this item is exist, notice user string mess = "Item code: " + lbItem.Item_Number + " and Invoice: " + lbItem.Invoice + "is exist!" + Environment.NewLine; mess += "Total stock-in: " + totalStockIn + Environment.NewLine + "Total packing: " + totalPacking + Environment.NewLine; mess += "Are you sure add new packing with this Invoice?" + Environment.NewLine + "Bạn có muốn thêm gói mới với mã hóa đơn này không?"; if (CustomMessageBox.Question(mess) == DialogResult.No) { return; } } } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } #endregion for (int i = 0; i < labelQty; i++) { #region CHECK INVOICE AND CREATE PACKING CODE //Get max number packing of this Invoice in database foreach (pts_stock item in stockItem.listStockItems) { if (!string.IsNullOrEmpty(item.invoice)) { temp = int.Parse(item.packing_cd.Substring(item.invoice.Length + 1)); } else { temp = int.Parse(item.packing_cd.Substring(5)); } if (temp > n) { n = temp; } } //Create new number of packing with Invoice number foreach (pts_stock item in listStockItem) { if (item.invoice == lbItem.Invoice) { if (!string.IsNullOrEmpty(item.invoice)) { temp = int.Parse(item.packing_cd.Substring(item.invoice.Length + 1)); } else { temp = int.Parse(item.packing_cd.Substring(5)); } if (temp > n) { n = temp; } } } n++; if (!string.IsNullOrEmpty(lbItem.Invoice)) { invoice = lbItem.Invoice; } string packingcd = invoice + "-" + n.ToString("00"); #endregion //Add new barcode item into list stock item listStockItem.Add(new pts_stock { item_cd = lbItem.Item_Number, supplier_cd = txtSupplierCD.Text, invoice = lbItem.Invoice, stockin_date = lbItem.Delivery_Date, stockin_qty = lbItem.Delivery_Qty, stockin_user_cd = txtUserCD.Text, //order_no = orderno, packing_cd = packingcd, packing_qty = lbItem.Delivery_Qty, registration_user_cd = UserData.usercode, }); if (lbItem.Remark != "P") { listInputPremac.Add(new pre_649 { item_number = lbItem.Item_Number, item_name = lbItem.Item_Name, supplier_cd = txtSupplierCD.Text, supplier_name = txtSupplierName.Text, supplier_invoice = lbItem.Invoice, delivery_date = lbItem.Delivery_Date, delivery_qty = lbItem.Delivery_Qty, incharge = txtUserCD.Text, //order_number = orderno, }); } } UpdateInspectionGrid(); } catch (IndexOutOfRangeException) { CustomMessageBox.Error("Wrong format barcode!" + Environment.NewLine + "Please check barcode and try again!"); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }