Пример #1
0
 public void fill_grid(DataTable dtb)
 {
     try {
         if (dtb.Rows.Count > 0)
         {
             DGV_SALES.Rows.Clear();
             total_disc = 0; Total_Amount = 0;
             for (int i = 0; i < dtb.Rows.Count; i++)
             {
                 DGV_SALES.Rows.Add();
                 DGV_SALES.Rows[i].Cells["SLNO"].Value          = num;
                 DGV_SALES.Rows[i].Cells["InvNumber"].Value     = dtb.Rows[i]["InvNumber"].ToString();
                 DGV_SALES.Rows[i].Cells["InvDate"].Value       = Convert.ToDateTime(dtb.Rows[i]["InvDate"].ToString()).ToString("dd-MM-yyyy");
                 DGV_SALES.Rows[i].Cells["cust_number"].Value   = dtb.Rows[i]["cust_number"].ToString();
                 DGV_SALES.Rows[i].Cells["cust_name"].Value     = dtb.Rows[i]["cust_name"].ToString();
                 DGV_SALES.Rows[i].Cells["modeofpayment"].Value = dtb.Rows[i]["PayMethod"].ToString();
                 DGV_SALES.Rows[i].Cells["clDiscount"].Value    = dtb.Rows[i]["Discount"].ToString();
                 DGV_SALES.Rows[i].Cells["TotalAmount"].Value   = dtb.Rows[i]["TotalAmount"].ToString();
                 num = num + 1;
             }
             if (DGV_SALES.Rows.Count > 0)
             {
                 foreach (DataGridViewRow dr in DGV_SALES.Rows)
                 {
                     total_disc   = total_disc + Convert.ToDecimal(dr.Cells["clDiscount"].Value.ToString());
                     Total_Amount = Total_Amount + Convert.ToDecimal(dr.Cells["TotalAmount"].Value.ToString());
                 }
                 int total_inv = DGV_SALES.Rows.Count;
                 Txttotaldiscount.Text = total_inv.ToString("##.00");
                 Txtgrandtotal.Text    = Total_Amount.ToString("##.00");
                 Txt_totalInvoice.Text = total_inv.ToString();
             }
         }
     }
     catch (Exception ex)
     { MessageBox.Show(ex.Message, "Error !..", MessageBoxButtons.OK, MessageBoxIcon.Error); }
 }
Пример #2
0
        private void DVPrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            SqlConnection con = new SqlConnection(Helper.con);

            con.Open();
            SqlTransaction tran = con.BeginTransaction();

            SqlCommand cmd1 = new SqlCommand("select top 1 InvioceID2 from EditedBill order by InvioceID2 DESC", con, tran);

            cmd1.ExecuteNonQuery();

            using (SqlDataReader dr = cmd1.ExecuteReader())
            {
                while (dr.Read())
                {
                    //INVOICEID_1 = Convert.ToString(dr["InvioceID2"]);
                    INVOICEID_1 = Convert.ToString(dgv1.Rows[0].Cells[0].Value);

                    SqlCommand cmd2 = new SqlCommand("select InvioceID,Totalqty," +
                                                     "TotalAmount,TotalAmountWithGST,ActualAmount," +
                                                     "DiscountInPercent from Bill where InvioceID = '" + INVOICEID_1 + "' ", con, tran);
                    cmd2.ExecuteNonQuery();

                    using (SqlDataReader dr2 = cmd2.ExecuteReader())
                    {
                        while (dr2.Read())
                        {
                            INVOICEID_2   = Convert.ToString(dr2["InvioceID"]);
                            Total_Qty     = Convert.ToString(dr2["Totalqty"]);
                            Total_Amount  = Convert.ToString(dr2["TotalAmount"]);
                            _TotalWithGST = Convert.ToString(dr2["TotalAmountWithGST"]);
                            Actual_Amount = Convert.ToString(dr2["ActualAmount"]);
                            _Discount     = Convert.ToString(dr2["DiscountInPercent"]);
                        }
                    }
                }
            }

            tran.Commit();
            con.Close();

            e.Graphics.DrawString("FOODIES CLUB", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, new Point(60, 30));
            //e.Graphics.DrawString("GST# 222-333-123456", new Font("Arial", 10, FontStyle.Regular), Brushes.Black, new Point(130, 70));
            e.Graphics.DrawString("Invoice ID :", new Font("Arial", 8, FontStyle.Regular), Brushes.Black, new Point(10, 70));
            e.Graphics.DrawString(INVOICEID_2.ToString(), new Font("Arial", 8, FontStyle.Bold), Brushes.Black, new Point(90, 70));
            e.Graphics.DrawString("Transaction Date :", new Font("Arial", 8, FontStyle.Regular), Brushes.Black, new Point(10, 90));
            e.Graphics.DrawString(DateTime.Now.Date.ToShortDateString(), new Font("Arial", 8, FontStyle.Regular), Brushes.Black, new Point(130, 90));
            e.Graphics.DrawString("Transaction Time :", new Font("Arial", 8, FontStyle.Regular), Brushes.Black, new Point(10, 110));
            e.Graphics.DrawString(DateTime.Now.ToShortTimeString(), new Font("Arial", 8, FontStyle.Regular), Brushes.Black, new Point(130, 110));
            //
            e.Graphics.DrawString("------------------------------------------------------",
                                  new Font("Arial", 10, FontStyle.Regular), Brushes.Black, new Point(10, 130));
            e.Graphics.DrawString("SALES ITEMS", new Font("Arial", 10, FontStyle.Bold), Brushes.Black, new Point(80, 150));
            e.Graphics.DrawString("------------------------------------------------------",
                                  new Font("Arial", 10, FontStyle.Regular), Brushes.Black, new Point(10, 170));
            //
            e.Graphics.DrawString("PRODUCT NAME", new Font("Arial", 7, FontStyle.Bold), Brushes.Black, new Point(5, 190));
            e.Graphics.DrawString("QUANTITY", new Font("Arial", 7, FontStyle.Bold), Brushes.Black, new Point(120, 190));
            e.Graphics.DrawString("RATE", new Font("Arial", 7, FontStyle.Bold), Brushes.Black, new Point(180, 190));
            e.Graphics.DrawString("AMOUNT", new Font("Arial", 7, FontStyle.Bold), Brushes.Black, new Point(220, 190));

            int position = 210;

            for (int i = 0; i < dgv1.Rows.Count; i++)
            {
                position = position + 20;
                e.Graphics.DrawString(Convert.ToString(dgv1.Rows[i].Cells[4].Value), new Font("Arial", 8, FontStyle.Regular), Brushes.Black, new Point(5, position));
                e.Graphics.DrawString(Convert.ToString(dgv1.Rows[i].Cells[5].Value) + ".00", new Font("Arial", 8, FontStyle.Regular), Brushes.Black, new Point(135, position));
                e.Graphics.DrawString(Convert.ToString(dgv1.Rows[i].Cells[6].Value) + ".00", new Font("Arial", 8, FontStyle.Regular), Brushes.Black, new Point(175, position));
                e.Graphics.DrawString(Convert.ToString(dgv1.Rows[i].Cells[7].Value) + ".00", new Font("Arial", 8, FontStyle.Regular), Brushes.Black, new Point(225, position));
            }
            //
            e.Graphics.DrawString("------------------------------------------------------",
                                  new Font("Arial", 10, FontStyle.Regular), Brushes.Black, new Point(10, position + 20));
            //
            e.Graphics.DrawString("Actual Amount", new Font("Arial", 8, FontStyle.Bold), Brushes.Black, new Point(10, position + 40));
            e.Graphics.DrawString(Actual_Amount.ToString() + ".00", new Font("Arial", 8, FontStyle.Bold), Brushes.Black, new Point(190, position + 40));
            e.Graphics.DrawString("Total Quantity", new Font("Arial", 8, FontStyle.Bold), Brushes.Black, new Point(10, position + 60));
            e.Graphics.DrawString(Total_Qty.ToString() + ".00", new Font("Arial", 8, FontStyle.Bold), Brushes.Black, new Point(190, position + 60));
            e.Graphics.DrawString("Total Amount", new Font("Arial", 8, FontStyle.Bold), Brushes.Black, new Point(10, position + 80));
            e.Graphics.DrawString(Total_Amount.ToString() + ".00", new Font("Arial", 8, FontStyle.Bold), Brushes.Black, new Point(190, position + 80));
            e.Graphics.DrawString("Discount", new Font("Arial", 8, FontStyle.Bold), Brushes.Black, new Point(10, position + 100));
            e.Graphics.DrawString(discountpercentageForAmount.ToString() + " %", new Font("Arial", 8, FontStyle.Bold), Brushes.Black, new Point(190, position + 100));
            //
            e.Graphics.DrawString("------------------------------------------------------",
                                  new Font("Arial", 10, FontStyle.Regular), Brushes.Black, new Point(10, position + 120));
            //
            e.Graphics.DrawString("TOKEN NO " + INVOICEID_2.ToString(), new Font("Arial", 10, FontStyle.Bold), Brushes.Black, new Point(10, position + 140));
        }