Пример #1
0
 private void InvoiceReportGrid_Click(object sender, System.EventArgs e)
 {
     int invoiceID;
     if (InvoiceReportGrid.CurrentCell.ColumnNumber == 4 && ((MainForm)MdiParent).User.IsManager())
     {
         invoiceID = int.Parse(Table.Rows[InvoiceReportGrid.CurrentCell.RowNumber]["invoiceid"].ToString());
         bool selected = !(bool)(Table.Rows[InvoiceReportGrid.CurrentCell.RowNumber]["Selected"]);
         for (int i = 0;i < Table.Rows.Count;i++)
             if (Table.Rows[i]["invoiceid"].ToString() == invoiceID.ToString())
                 Table.Rows[i]["Selected"] = selected;
         BusinessService.BusinessService service = new BusinessService.BusinessService();
         service.UpdateInvoiceHidden(invoiceID, selected);
         UpdateInvoiceSummaryReport();
     }
     else if (InvoiceReportGrid.CurrentCell.ColumnNumber == 5 ||
         InvoiceReportGrid.CurrentCell.ColumnNumber == 4 && ((MainForm)MdiParent).User.IsAuditor())
     {
         invoiceID = int.Parse(Table.Rows[InvoiceReportGrid.CurrentCell.RowNumber]["invoiceid"].ToString());
         InvoiceViewerForm.Show(invoiceID);
     }
 }
Пример #2
0
 private void UpdateInvoiceReport()
 {
     PanelInvoiceReport.BringToFront();
     BusinessService.BusinessService service = new BusinessService.BusinessService();
     DataTable dTable = ReportConverter.Convert(service.GetInvoiceReport(DateInvoiceReport.Value, ((MainForm)MdiParent).User.EmployeeTypeID));
     if (dTable == null)
         return;
     // Add order column
     if (((MainForm)MdiParent).User.IsManager())
         dTable.Columns.Add("Selected", typeof(bool));
     dTable.Columns.Add("View", typeof(bool));
     dTable.Columns.Add("No.", typeof(string));
     string oldInvoiceID = "";
     int cnt = 1;
     for (int i = 0;i < dTable.Rows.Count;i++)
     {
         bool selected = (dTable.Rows[i]["hidden"].ToString() == "True");
         if (((MainForm)MdiParent).User.IsManager())
             dTable.Rows[i]["Selected"] = (dTable.Rows[i]["hidden"].ToString() == "True");
         dTable.Rows[i]["View"] = false;
         if (oldInvoiceID == dTable.Rows[i]["invoiceid"].ToString())
         {
             dTable.Rows[i]["No."] = "";
             continue;
         }
         dTable.Rows[i]["No."] = (cnt++).ToString();
         oldInvoiceID = dTable.Rows[i]["invoiceid"].ToString();
     }
     dTable.Columns.Remove("hidden");
     // Bind data to data grid
     InvoiceReportGrid.DataSource = dTable;
     DataGridTableStyle tStyle = new DataGridTableStyle();
     tStyle.RowHeadersVisible = false;
     tStyle.PreferredRowHeight = 32;
     tStyle.PreferredColumnWidth = (InvoiceReportGrid.Width - 66) / (dTable.Columns.Count - 3);
     tStyle.HeaderBackColor = Color.Black;
     tStyle.HeaderForeColor = Color.White;
     tStyle.AllowSorting = false;
     // Manage Column
     DataGridColumnStyle cStyle = new DataGridTextBoxColumn();
     cStyle.HeaderText = "No.";
     cStyle.MappingName = "No.";
     cStyle.Alignment = HorizontalAlignment.Center;
     cStyle.Width = 50;
     tStyle.GridColumnStyles.Add(cStyle);
     for (int i = 2;i < dTable.Columns.Count - 1;i++)
     {
         if (i >= 5)
             cStyle = new DataGridBoolColumn();
         else
             cStyle = new DataGridTextBoxColumn();
         cStyle.HeaderText = dTable.Columns[i].ColumnName;
         cStyle.MappingName = dTable.Columns[i].ColumnName;
         cStyle.Alignment = HorizontalAlignment.Center;
         cStyle.ReadOnly = false;
         tStyle.GridColumnStyles.Add(cStyle);
     }
     InvoiceReportGrid.TableStyles.Clear();
     InvoiceReportGrid.TableStyles.Add(tStyle);
     Table = dTable;
     UpdateInvoiceSummaryReport();
 }
Пример #3
0
 private void BtnPrintInvoiceReport_Click(object sender, System.EventArgs e)
 {
     WaitingForm.Show("Print Invoice Report");
     this.Enabled = false;
     BusinessService.BusinessService service = new BusinessService.BusinessService();
     service.PrintInvoiceReport(DateInvoiceReport.Value, ((MainForm)MdiParent).User.EmployeeTypeID);
     this.Enabled = true;
     WaitingForm.HideForm();
 }
Пример #4
0
 private void BtnSumPayment_Click(object sender, System.EventArgs e)
 {
     BusinessService.BusinessService service = new BusinessService.BusinessService();
     WaitingForm.Show("Print Summary");
     service.PrintSummaryReceive(SummaryDate.Value);
     WaitingForm.HideForm();
 }
Пример #5
0
 private void BtnExport_Click(object sender, System.EventArgs e)
 {
     if (DateExportFrom.Value > DateExportTo.Value)
     {
         MessageForm.Show("Export Invoice", "Please select from date less or equal to date.");
         return;
     }
     BusinessService.BusinessService service = new BusinessService.BusinessService();
     DataTable dTable = ReportConverter.Convert(service.ExportInvoice(DateExportFrom.Value, DateExportTo.Value));
     if (dTable == null)
     {
         MessageForm.Show("Export Invoice", "No invoice in range to export.");
         return;
     }
     // Create output file
     DateTime now = DateTime.Now;
     StringBuilder sb = new StringBuilder();
     CheckBillService.CheckBillService bService = new CheckBillService.CheckBillService();
     string path = bService.GetDescription("EXPORT_PATH");
     sb.Append(path);
     sb.Append("invoice_");
     sb.Append(now.ToString("yyyyMMddhhmmss"));
     sb.Append(".csv");
     StreamWriter sw = File.CreateText(sb.ToString());
     // Write Header
     sb.Length = 0;
     sb.Append("Export Invoice when ");
     sb.Append(now.ToString("dd/MM/yyyy hh:mm:ss"));
     sw.WriteLine(sb.ToString());
     sb.Length = 0;
     for (int i = 0;i < dTable.Columns.Count;i++)
     {
         if (i > 0)
             sb.Append(",\"");
         else
             sb.Append("\"");
         sb.Append(dTable.Columns[i].ColumnName);
         sb.Append("\"");
     }
     sw.WriteLine(sb.ToString());
     // Write Data
     for (int i = 0;i < dTable.Rows.Count;i++)
     {
         DataRow row = dTable.Rows[i];
         sb.Length = 0;
         for (int j = 0;j < row.ItemArray.Length;j++)
         {
             if (j > 0)
                 sb.Append(",");
             sb.Append(row[j].ToString());
         }
         sw.WriteLine(sb.ToString());
     }
     sw.Close();
     MessageForm.Show("Export Invoice", "Export Invoice Completed...");
 }
Пример #6
0
 private void BtnDelete_Click(object sender, System.EventArgs e)
 {
     BusinessService.BusinessService service = new BusinessService.BusinessService();
     service.DeleteSelected();
     MessageForm.Show("Void Selected", "Void Selected Completed...");
 }
Пример #7
0
 private void BtnBackup_Click(object sender, System.EventArgs e)
 {
     BusinessService.BusinessService service = new BusinessService.BusinessService();
     service.BackupDatabase();
     MessageForm.Show("Backup Database", "Backup Database Completed...");
 }
Пример #8
0
 private void UpdateSalesReport()
 {
     PanelSalesReport.BringToFront();
     BusinessService.BusinessService service = new BusinessService.BusinessService();
     DataTable dTable = ReportConverter.Convert(service.GetSalesReport(DateSalesReport.Value, ((MainForm)MdiParent).User.EmployeeTypeID));
     if (dTable == null)
         return;
     // Compute total
     double[] sum = new double[dTable.Columns.Count - 1];
     for (int i = 0;i < dTable.Rows.Count;i++)
     {
         for (int j = 1;j < dTable.Columns.Count;j++)
         {
             double p = double.Parse(dTable.Rows[i][j].ToString());
             dTable.Rows[i][j] = p.ToString("N");
             sum[j - 1] += p;
         }
     }
     // Create total table
     DataTable tTable = new DataTable();
     for (int i = 0;i < dTable.Columns.Count;i++)
         tTable.Columns.Add(new DataColumn(dTable.Columns[i].ColumnName));
     DataRow row = tTable.NewRow();
     row[0] = "Total";
     for (int i = 1;i < dTable.Columns.Count;i++)
         row[i] = sum[i - 1].ToString("N");
     tTable.Rows.Add(row);
     // Bind data to data grid
     ReportGrid.DataSource = dTable;
     DataGridTableStyle tStyle = new DataGridTableStyle();
     tStyle.RowHeadersVisible = false;
     tStyle.PreferredRowHeight = 32;
     tStyle.PreferredColumnWidth = (ReportGrid.Width - 16) / dTable.Columns.Count;
     tStyle.HeaderBackColor = Color.Black;
     tStyle.HeaderForeColor = Color.White;
     for (int i = 0;i < dTable.Columns.Count;i++)
     {
         DataGridColumnStyle cStyle = new DataGridTextBoxColumn();
         if (i == 0)
             cStyle.HeaderText = "";
         else
             cStyle.HeaderText = dTable.Columns[i].ColumnName;
         cStyle.MappingName = dTable.Columns[i].ColumnName;
         cStyle.Alignment = HorizontalAlignment.Center;
         tStyle.GridColumnStyles.Add(cStyle);
     }
     ReportGrid.TableStyles.Clear();
     ReportGrid.TableStyles.Add(tStyle);
     // Bind total to total grid
     TotalGrid.DataSource = tTable;
     tStyle = new DataGridTableStyle();
     tStyle.RowHeadersVisible = false;
     tStyle.ColumnHeadersVisible = false;
     tStyle.PreferredRowHeight = 32;
     tStyle.PreferredColumnWidth = (TotalGrid.Width - 16) / tTable.Columns.Count;
     tStyle.BackColor = Color.DarkRed;
     tStyle.ForeColor = Color.White;
     for (int i = 0;i < tTable.Columns.Count;i++)
     {
         DataGridColumnStyle cStyle = new DataGridTextBoxColumn();
         cStyle.HeaderText = "";
         cStyle.MappingName = tTable.Columns[i].ColumnName;
         cStyle.Alignment = HorizontalAlignment.Center;
         tStyle.GridColumnStyles.Add(cStyle);
     }
     TotalGrid.TableStyles.Clear();
     TotalGrid.TableStyles.Add(tStyle);
 }
Пример #9
0
 private void UpdateInvoiceSummaryReport()
 {
     // Invoice Summary
     BusinessService.BusinessService service = new BusinessService.BusinessService();
     DataTable dTable = ReportConverter.Convert(service.GetInvoiceSummaryReport(DateInvoiceReport.Value, ((MainForm)MdiParent).User.EmployeeTypeID));
     if (dTable == null)
         return;
     // Change text format
     for (int i = 0;i < dTable.Rows.Count;i++)
     {
         for (int j = 1;j < dTable.Columns.Count;j++)
         {
             double p = double.Parse(dTable.Rows[i][j].ToString());
             dTable.Rows[i][j] = p.ToString("N");
         }
     }
     // Bind data to data grid
     InvoiceSummaryGrid.DataSource = dTable;
     DataGridTableStyle tStyle = new DataGridTableStyle();
     tStyle.RowHeadersVisible = false;
     tStyle.PreferredRowHeight = 32;
     tStyle.PreferredColumnWidth = (InvoiceSummaryGrid.Width - 16) / dTable.Columns.Count;
     tStyle.HeaderBackColor = Color.Black;
     tStyle.HeaderForeColor = Color.White;
     for (int i = 0;i < dTable.Columns.Count;i++)
     {
         DataGridColumnStyle cStyle = new DataGridTextBoxColumn();
         if (i == 0)
             cStyle.HeaderText = "";
         else
             cStyle.HeaderText = dTable.Columns[i].ColumnName;
         cStyle.MappingName = dTable.Columns[i].ColumnName;
         cStyle.Alignment = HorizontalAlignment.Center;
         tStyle.GridColumnStyles.Add(cStyle);
     }
     InvoiceSummaryGrid.TableStyles.Clear();
     InvoiceSummaryGrid.TableStyles.Add(tStyle);
 }