/// <summary> /// Delete stock item /// </summary> private void DeleteStock() { try { listStockLog.Clear(); //Get all old data of fields in stock item for (int i = 0; i < oldStockData.GetType().GetProperties().Length; i++) { stockLog = new pts_stock_log { log_action = "Delete", log_user_cd = UserData.usercode, stock_id = oldStockData.stock_id.ToString(), stock_field = oldStockData.GetType().GetProperties()[i].Name, before_value = oldStockData.GetType().GetProperties()[i].GetValue(oldStockData).ToString(), after_value = "Deleted" }; //Add logs item into list listStockLog.Add(stockLog); } int id = oldStockData.stock_id; int n = stockLog.AddMultiLog(listStockLog); //Delete stock data oldStockData.DeleteItem(); CustomMessageBox.Notice("Deleted item : " + id + " Successful!" + Environment.NewLine + "Update " + n + " logs!"); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
private void btnManualPrint_Click(object sender, EventArgs e) { try { if (printItem.CheckPrinterIsOffline(SettingItem.printerSName)) { CustomMessageBox.Notice("Printer is offline"); return; } listPrintItem.Clear(); if (dgvPrintList.SelectedRows.Count == 0) { CustomMessageBox.Notice("Please choose item first!"); return; } foreach (DataGridViewRow dr in dgvPrintList.SelectedRows) { listPrintItem.Add(dr.DataBoundItem as PrintItem); dr.DefaultCellStyle.BackColor = Color.Yellow; } if (printItem.PrintItems(listPrintItem, true)) { CustomMessageBox.Notice("Print items are completed!"); } } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == Keys.F2) { try { //Press F2 for add new supplier supplierItem.AddSupplier(new pts_supplier { supplier_cd = txtSupplierCD.Text, supplier_name = txtSupplierName.Text, registration_user_cd = UserData.usercode, }); CustomMessageBox.Notice("New supplier has been added with supplier code : " + txtSupplierCD.Text + Environment.NewLine + "NSX mới được thêm vào với mã: " + txtSupplierCD.Text); txtSupplierCD.Clear(); errorProvider.SetError(txtSupplierCD, null); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } txtBarcode.Focus(); return(true); } return(base.ProcessCmdKey(ref msg, keyData)); }
private void btnManualPrint_Click(object sender, EventArgs e) { try { if (printItem.CheckPrinterIsOffline(SettingItem.printerSName)) { CustomMessageBox.Notice("Printer is offline" + Environment.NewLine + "Máy in chưa kết nối!"); return; } listPrintItem.Clear(); if (dgvPrintList.SelectedRows.Count == 0) { CustomMessageBox.Notice("Please choose item first!" + Environment.NewLine + "Vui lòng chọn tem muốn in!"); return; } foreach (DataGridViewRow dr in dgvPrintList.SelectedRows) { listPrintItem.Add(dr.DataBoundItem as PrintItem); dr.DefaultCellStyle.BackColor = Color.Yellow; } if (printItem.PrintItems(listPrintItem, int.Parse(txtPrintLabelQty.Text))) { CustomMessageBox.Notice("Print " + txtPrintLabelQty.Text + " items are completed!" + Environment.NewLine + "Đã in " + txtPrintLabelQty.Text + " tem!"); } txtPrintLabelQty.Text = "1"; } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
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 btnStockOutReg_Click(object sender, EventArgs e) { try { int n = 0; //Add no-plan item into DB if (listNoPlan.Count > 0) { n = noplanData.AddMultiItem(listNoPlan); CustomMessageBox.Notice("Add " + n + " No-Planned item successed!"); } //Add stock-out logs into DB if (listStockOut.Count > 0) { n = stockOutData.AddMultiItem(listStockOut); outData.ExportCSV(outData.listOutputItem); CustomMessageBox.Notice("Add " + n + " Stock-Out logs!"); } //Update packing qty of stock item in DB foreach (pts_stock item in listStock) { item.UpdateItem(item); } //Update stock qty itemData.ListStockOutUpdateValue(outData.listOutputItem); CustomMessageBox.Notice("Register completed!"); ClearInspection(); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
private void btnPrintAll_Click(object sender, EventArgs e) { try { if (printItem.CheckPrinterIsOffline(SettingItem.printerSName)) { CustomMessageBox.Notice("Printer is offline" + Environment.NewLine + "Máy in chưa kết nối!"); return; } listPrintItem.Clear(); if (dgvPrintList.Rows.Count == 0) { CustomMessageBox.Error("Don't have item to print!" + Environment.NewLine + "Không có tem để in!"); return; } foreach (DataGridViewRow dr in dgvPrintList.Rows) { listPrintItem.Add(dr.DataBoundItem as PrintItem); dr.DefaultCellStyle.BackColor = Color.Lime; } if (printItem.PrintItems(listPrintItem, false)) { CustomMessageBox.Notice("Print items are completed!" + Environment.NewLine + "In hoàn tất!"); } } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
private void btnAdd_Click(object sender, EventArgs e) { try { txtPlanCD.Text = "plan-" + DateTime.Now.ToString("yyyyMMdd-HHmmss"); planData.Add(new pts_plan { plan_cd = txtPlanCD.Text, plan_usercd = txtUserCD.Text, model_cd = txtModelCD.Text, set_number = txtSetNumber.Text, destination_cd = des_cd, plan_qty = double.Parse(txtPlanQty.Text), plan_date = dtpPlanDate.Value, delivery_date = dtpDeliveryDate.Value, comment = txtComment.Text, }); CustomMessageBox.Notice("Add new plan successed!"); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } UpdateGrid(false); }
private void btnDelete_Click(object sender, EventArgs e) { try { planData.Delete(); CustomMessageBox.Notice("Delet plan successed!"); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } UpdateGrid(false); }
public void Show() { var isExist = Application.OpenForms.OfType <FormCommon>().Where(x => x.Name == base.Name).Select(x => x); if (isExist.Count() > 0) { CustomMessageBox.Notice(base.Text + " is openning! Please close it first!" + Environment.NewLine + "Có một cửa sổ tương tự đang mở!"); return; } else { base.Show(); } }
private void btnDelMaster_Click(object sender, EventArgs e) { try { tbl_inspect_master masterData = dgvMain.SelectedRows[0].DataBoundItem as tbl_inspect_master; int n = masterData.Delete(masterData.inspect_id); CustomMessageBox.Notice("Deleted " + n + " master inspect!" + Environment.NewLine + "Đã xóa " + n + " hạng mục!"); UpdateGrid(true); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
private void txtNewPass_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab) { if (txtNewPass.Text.Length < 6) { CustomMessageBox.Notice("Password contains at least 6 character!"); txtNewPass.Focus(); } else { txtConfirmPass.Focus(); } } }
private void btnExport_Click(object sender, EventArgs e) { try { OpenFileDialog openFrm = new OpenFileDialog(); openFrm.Filter = "CSV document (*.csv)|*.csv|Text file (*.txt)|*.txt|All file (*.*)|*.*"; if (openFrm.ShowDialog() == DialogResult.OK) { stockData.ExportToCSV((List <pts_stock>)dgvStockDetail.DataSource, openFrm.FileName); } CustomMessageBox.Notice("Export data to " + openFrm.FileName + " completed!"); } 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(); }
private void btnExport_Click(object sender, EventArgs e) { try { string boxCode = string.Empty; string partCode = string.Empty; tbl_part_box boxData = new tbl_part_box(); tbl_inspect_data insData = new tbl_inspect_data(); tbl_inspect_master masterData = new tbl_inspect_master(); if (IsBoxMode) { if (dgvMain.SelectedRows.Count <= 0) { CustomMessageBox.Notice("Please choose a box!" + Environment.NewLine + "Vui lòng chọn 1 box!"); return; } boxData = dgvMain.SelectedRows[0].DataBoundItem as tbl_part_box; boxCode = boxData.part_box_cd; partCode = boxData.part_number; } else { boxCode = txtBoxID.Text; partCode = txtPartNumber.Text; } insData.Search(boxCode); boxData.Search(new tbl_part_box { part_box_cd = boxCode }, false); masterData.Search(new tbl_inspect_master { inspect_id = 0, part_number = partCode }); ExcelClassnew excel = new ExcelClassnew(); excel.exportExcelIQC(boxData.listBox[0], masterData.listMaster, insData.listData); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }
private void btnRegister_Click(object sender, EventArgs e) { try { tbl_inspect_master masterData = new tbl_inspect_master(); int n = masterData.Add(new tbl_inspect_master { inspect_cd = txtInsCode.Text, part_number = txtInsPart.Text, inspect_name = txtInsName.Text, inspect_tool = cmbInsTool.Text, inspect_spec = double.Parse(txtInsSpec.Text), tol_plus = double.Parse(txtInsPlus.Text), tol_minus = double.Parse(txtInsMinus.Text) }); CustomMessageBox.Notice("Add " + n + " master inspect!" + Environment.NewLine + "Đã thêm " + n + " hạng mục!"); } catch (Exception ex) { CustomMessageBox.Error(ex.Message); } }