private void txtGetListExcel_Click(object sender, EventArgs e) { try { operationDistribution = OperationDistribution.FileListExcel; stStatus.Invoke(new MethodInvoker(delegate { stsStatus.Text = ""; stsStatus.ForeColor = Color.White; stsStatus.BackColor = Color.Green; if (tstxtPath.Text.Trim() == "") { stsStatus.Text = "Please choise folder path!"; stsStatus.ForeColor = Color.White; stsStatus.BackColor = Color.Red; return; } })); //cheAll cheAll.Invoke(new MethodInvoker(delegate { cheAll.Checked = false; })); pcloader.Visible = true; pcloader.Dock = DockStyle.Fill; backgroundWorker1.RunWorkerAsync(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void tsBtnGetDataFromDB_Click(object sender, EventArgs e) { try { frmDistributionChoisePO f = new frmDistributionChoisePO(); f.ShowDialog(); if (f.IdDsChoise != string.Empty) { currentIdDsChoise = f.IdDsChoise; operationDistribution = OperationDistribution.LoadDataromDB; pcloader.Visible = true; pcloader.Dock = DockStyle.Fill; backgroundWorker1.RunWorkerAsync(); } else { MessageBox.Show("Must choising Lis PO!"); } } catch (Exception) { MessageBox.Show("Get data from Database be error!"); } }
private void sdbtnLoadDataExcel_Click(object sender, EventArgs e) { try { if (dgvListFile.Rows.Count > 0) { operationDistribution = OperationDistribution.LoadDataExcel; pcloader.Visible = true; pcloader.Dock = DockStyle.Fill; backgroundWorker1.RunWorkerAsync(); } else { MessageBox.Show("Don't have the list that need to read data!"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void tsBtnPrinter_Click(object sender, EventArgs e) { try { int totalBill = 0; string listID = ""; dgvListFile.Invoke(new MethodInvoker(delegate { for (int i = 0; i < dgvListFile.Rows.Count; i++) { if (dgvListFile.Rows[i].Cells["Check"].Value != null) { if ((bool)dgvListFile.Rows[i].Cells["Check"].Value == true) { string id = dgvListFile.Rows[i].Cells["Id"].Value.ToString(); listID += $"{id},"; totalBill++; } } } })); if (totalBill == 0) { return; } if (MessageBox.Show($"Total bill: {totalBill}, Are you sure?", "Confirm printer for distrubution bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes) { #region Save if (listID.Length > 0) { listID = listID.Substring(0, listID.Length - 1); idList = listID.Split(','); if (idList != null && idList.Length > 0) { operationDistribution = OperationDistribution.PrinterListBill; //stStatus.Invoke(new MethodInvoker(delegate //{ // stsStatus.Text = ""; // stsStatus.ForeColor = Color.White; // stsStatus.BackColor = Color.Green; // if (tstxtPath.Text.Trim() == "") // { // stsStatus.Text = "Saveing data to Database..."; // stsStatus.ForeColor = Color.White; // stsStatus.BackColor = Color.Red; // return; // } //})); pcloader.Visible = true; pcloader.Dock = DockStyle.Fill; backgroundWorker1.RunWorkerAsync(); } else { MessageBox.Show("Please choise item that save data to database!"); } } #endregion } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void sbbtnSaveDataToDB_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Do you want to save data to database?", "Confirm Save data to Database", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes) { #region Save string listID = ""; dgvListFile.Invoke(new MethodInvoker(delegate { for (int i = 0; i < dgvListFile.Rows.Count; i++) { if (dgvListFile.Rows[i].Cells["Check"].Value != null) { if ((bool)dgvListFile.Rows[i].Cells["Check"].Value == true) { string id = dgvListFile.Rows[i].Cells["Id"].Value.ToString(); listID += $"{id},"; } } } })); if (listID.Length > 0) { listID = listID.Substring(0, listID.Length - 1); idList = listID.Split(','); if (idList != null && idList.Length > 0) { distibution = new Distibution(); distibution.Id = Guid.NewGuid(); distibution.User = Core.User; distibution.Name = $"(DIS-{distibution.User}-{ DateTime.Now.ToString("yyyy-MM-dd:HH-mm-ss")}"; operationDistribution = OperationDistribution.SaveToDB; stStatus.Invoke(new MethodInvoker(delegate { stsStatus.Text = ""; stsStatus.ForeColor = Color.White; stsStatus.BackColor = Color.Green; if (tstxtPath.Text.Trim() == "") { stsStatus.Text = "Saveing data to Database..."; stsStatus.ForeColor = Color.White; stsStatus.BackColor = Color.Red; return; } })); //cheAll cheAll.Invoke(new MethodInvoker(delegate { cheAll.Checked = false; })); pcloader.Visible = true; pcloader.Dock = DockStyle.Fill; backgroundWorker1.RunWorkerAsync(); } else { MessageBox.Show("Please choise item that save data to database!"); } } #endregion } } catch (Exception) { MessageBox.Show("Save data to database be error!"); } }