private void cmdSearch_Click(object sender, EventArgs e) { if (!rangeDateBox1.FromDate.HasValue || !rangeDateBox1.ToDate.HasValue) { Error.ErrorMessage(rangeDateBox1, "isi"); return; } if (GlobalVar.PerusahaanRowID != GlobalVar.GetPT.SAP) { MessageBox.Show("Hanya Untuk login SAP"); this.Close(); return; } try { this.Cursor = Cursors.WaitCursor; DateTime FromDate = rangeDateBox1.FromDate.Value; DateTime ToDate = rangeDateBox1.ToDate.Value; Guid PT = (Guid)cboPers.SelectedValue; dtHeaderA = JournalPS.dtNota(FromDate, ToDate, PT); dtHeaderB = JournalPS.dtRetur(FromDate, ToDate, PT); dtHeaderC = JournalPS.dtKPJ(FromDate, ToDate, PT); dtHeaderD = JournalPS.dtKRJ(FromDate, ToDate, PT); dtHeaderE = JournalPS.dtIden(FromDate, ToDate, PT); GvHeaderA.AutoGenerateColumns = true; GVHeaderB.AutoGenerateColumns = true; GVHeaderC.AutoGenerateColumns = true; GVHeaderD.AutoGenerateColumns = true; GVHeaderE.AutoGenerateColumns = true; GvHeaderA.DataSource = dtHeaderA.DefaultView; GvHeaderA.Refresh(); GVHeaderB.DataSource = dtHeaderB.DefaultView; GVHeaderB.Refresh(); GVHeaderC.DataSource = dtHeaderC.DefaultView; GVHeaderC.Refresh(); GVHeaderD.DataSource = dtHeaderD.DefaultView; GVHeaderD.Refresh(); GVHeaderE.DataSource = dtHeaderE.DefaultView; GVHeaderE.Refresh(); foreach (TabPage TB in TabJournal.TabPages) { foreach (Control ctrX in TB.Controls) { if (ctrX is ISA.Controls.CustomGridView) { ISA.Controls.CustomGridView ctr = (ISA.Controls.CustomGridView)ctrX; foreach (DataGridViewColumn col in ctr.Columns) { if (col.Name.Contains("Row")) { col.Visible = false; } if (col.Name.Contains("HeaderID")) { col.Visible = false; } if (col.Name.Contains("RecordID")) { col.Visible = false; } if (col.Name.Contains("Tanggal") || col.Name.Contains("Tgl")) { col.DefaultCellStyle.Format = "dd-MM-yyyy"; } if (col.Name.Contains("Rp") || col.Name.Contains("Amount") || col.Name.Contains("Nominal")) { col.DefaultCellStyle.Format = "N2"; col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } if (col.Name.Contains("F")) { col.DefaultCellStyle.Format = "N2"; col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } if (col.Name.Contains("NoPer")) { col.Visible = false; } } } } } } catch (System.Exception ex) { Error.LogError(ex); } finally { this.Cursor = Cursors.Default; } }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { try { int X = dtHeaderA.DefaultView.Count; int i = 0; Msg = "Nota Penjualan"; backgroundWorker1.ReportProgress(1); foreach (DataRowView dr in dtHeaderA.DefaultView) { DataRow drr = dr.Row; JournalPS.AddJournalNota(drr); i++; backgroundWorker1.ReportProgress(i / X); } X = dtHeaderB.DefaultView.Count; i = 0; Msg = "Retur Penjualan"; backgroundWorker1.ReportProgress(1); foreach (DataRowView dr in dtHeaderB.DefaultView) { DataRow drr = dr.Row; JournalPS.AddJournalRetur(drr); i++; backgroundWorker1.ReportProgress(i / X); } X = dtHeaderC.DefaultView.Count; i = 0; Msg = "Koreksi Penjualan"; backgroundWorker1.ReportProgress(1); foreach (DataRowView dr in dtHeaderC.DefaultView) { DataRow drr = dr.Row; JournalPS.AddJournalKPJ(drr); i++; backgroundWorker1.ReportProgress(i / X); } X = dtHeaderD.DefaultView.Count; i = 0; Msg = "Koreksi Retur Penjualan"; backgroundWorker1.ReportProgress(1); foreach (DataRowView dr in dtHeaderD.DefaultView) { DataRow drr = dr.Row; JournalPS.AddJournalKRJ(drr); i++; backgroundWorker1.ReportProgress(i / X); } X = dtHeaderE.DefaultView.Count; i = 0; Msg = "Identifikasi Penjualan"; backgroundWorker1.ReportProgress(1); foreach (DataRowView dr in dtHeaderE.DefaultView) { DataRow drr = dr.Row; JournalPS.AddJournalIden(drr); i++; backgroundWorker1.ReportProgress(i / X); } } catch (System.Exception ex) { Error.LogError(ex); Msg = "Error"; backgroundWorker1.ReportProgress(0); } }