void SetupGridPrinter()
        {
            DataTable sampleDataTable = new DataTable("ATABLE");

            sampleDataTable.Columns.Add("Building Name", typeof(string));
            sampleDataTable.Columns.Add("Space unit", typeof(string));
            sampleDataTable.Columns.Add("Date", typeof(string));
            sampleDataTable.Columns.Add("Contractor Name", typeof(string));

            sampleDataTable.Columns.Add("Installment Due", typeof(string));
            sampleDataTable.Columns.Add("Contact No", typeof(string));
            // sampleDataTable.Columns.Add("Type", typeof(string));
            sampleDataTable.Columns.Add("Status", typeof(string));
            var report = da.GetMonthlyReport(DateTime.Parse(ddFromDate.Text), DateTime.Parse(ddToDate.Text), PaymentStatus.COMPLETE);

            DataRow sampleDataRow;

            foreach (var c in report)
            {
                sampleDataRow = sampleDataTable.NewRow();
                sampleDataRow["Building Name"]   = c.BuildingName.ToString(CultureInfo.CurrentCulture);
                sampleDataRow["Space unit"]      = c.Typeno.ToString(CultureInfo.CurrentCulture);
                sampleDataRow["Date"]            = c.Date.ToShortDateString();
                sampleDataRow["Contractor Name"] = c.Name;

                sampleDataRow["Installment Due"] = c.InstallmentAmount.ToString( );
                sampleDataRow["Contact No"]      = c.ContactNo.ToString(CultureInfo.CurrentCulture);
                // sampleDataRow["Type"] = c.Type;
                sampleDataRow["Status"] = c.Status;
            }

            dataGridPrinter1 = new DataGridPrinter(dataGridView1, printDocument1, sampleDataTable);
        }
Exemplo n.º 2
0
        void SetupGridPrinter()
        {
            DataTable sampleDataTable = new DataTable("ATABLE");

            sampleDataTable.Columns.Add("Building Name", typeof(string));
            sampleDataTable.Columns.Add("Space unit", typeof(string));
            sampleDataTable.Columns.Add("Date", typeof(string));
            sampleDataTable.Columns.Add("Contractor Name", typeof(string));
            if (!isMonthlyReport)
            {
                sampleDataTable.Columns.Add("Agreement", typeof(string));
            }
            sampleDataTable.Columns.Add("Installment Due", typeof(string));
            if (!isMonthlyReport)
            {
                sampleDataTable.Columns.Add("Contact No 1", typeof(string));
                sampleDataTable.Columns.Add("Contact No 2", typeof(string));
            }
            else
            {
                sampleDataTable.Columns.Add("Type", typeof(string));
            }
            sampleDataTable.Columns.Add("Status", typeof(string));

            var report = da.GetMonthlyReport(DateTime.Parse(ddFromDate.Text), DateTime.Parse(ddToDate.Text), isMonthlyReport ? PaymentStatus.COMPLETE : PaymentStatus.DUE);

            DataRow sampleDataRow;

            foreach (var c in report)
            {
                string[] contacts = c.ContactNo.Split('/');
                sampleDataRow = sampleDataTable.NewRow();
                sampleDataRow["Building Name"]   = c.BuildingName.ToString(CultureInfo.CurrentCulture);
                sampleDataRow["Space unit"]      = c.Typeno.ToString(CultureInfo.CurrentCulture);
                sampleDataRow["Date"]            = c.Date.ToShortDateString();
                sampleDataRow["Contractor Name"] = c.Name;
                if (!isMonthlyReport)
                {
                    sampleDataRow["Agreement"] = c.Agreement.ToString( );
                }
                sampleDataRow["Installment Due"] = c.InstallmentAmount.ToString( );
                if (!isMonthlyReport)
                {
                    sampleDataRow["Contact No 1"] = contacts[0].ToString(CultureInfo.CurrentCulture);
                    sampleDataRow["Contact No 2"] = contacts.Length > 1 ? contacts[1].ToString(CultureInfo.CurrentCulture) : "";
                }
                else
                {
                    sampleDataRow["Type"] = c.Type;
                }
                sampleDataRow["Status"] = c.Status;

                sampleDataTable.Rows.Add(sampleDataRow);
            }

            totalPages       = (sampleDataTable.Rows.Count + 14) / 25;
            dataGridPrinter1 = new DataGridPrinter(dataGridView1, printDocument1, sampleDataTable);
        }