protected void printBtn_Click(object sender, System.EventArgs e)
        {
            // The follwing code saves the credit bill as well as print it.
            if (DropCustID.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select the Customer Name");
                return;
            }
            string sql = "select sm.invoice_no, slip_no, invoice_date, vehicle_no, prod_Name+ ' ' +Pack_Type Prod_Name,qty, rate, amount from sales_master sm, sales_details sd, products p where sm.invoice_date between '" + ToMMddYYYY(txtDateFrom.Text) + "' and dateadd(day,1,'" + ToMMddYYYY(txtDateTO.Text) + "') and sm.cust_id in ( select cust_id from customer where cust_name=substring('" + DropCustID.SelectedItem.Value + "',1,charindex(':','" + DropCustID.SelectedItem.Value + "')-1)  and city=substring('" + DropCustID.SelectedItem.Value + "',charindex(':','" + DropCustID.SelectedItem.Value + "')+1,len('" + DropCustID.SelectedItem.Value + "'))) and sm.invoice_no = sd.invoice_no and sd.prod_id = p.prod_id";

            PetrolPumpClass obj     = new PetrolPumpClass();
            PetrolPumpClass obj1    = new PetrolPumpClass();
            SqlDataReader   SqlDtr2 = obj.GetRecordSet(sql);
            string          sql1    = "";

            try
            {
                while (SqlDtr2.Read())
                {
                    DateTime dt   = System.Convert.ToDateTime(SqlDtr2.GetValue(2).ToString());
                    string   str1 = dt.ToShortDateString();
                    string   str2 = SqlDtr2.GetValue(1).ToString();
                    string   str3 = SqlDtr2.GetValue(4).ToString();
                    string   str4 = SqlDtr2.GetValue(5).ToString();
                    string   str5 = SqlDtr2.GetValue(6).ToString();
                    string   str6 = SqlDtr2.GetValue(7).ToString();
                    string   str7 = SqlDtr2.GetValue(3).ToString();
                    sql1 = "insert into Print_Credit_Bill(Bill_No,Bill_date,Slip_no,Particulars,Qty,Rate,Amount,Vehicle_No)values('" + lblBillNo.Text.ToString() + "'," + str1 + "," + str2 + ",'" + str3 + "'," + str4 + "," + str5 + "," + str6 + ",'" + str7 + "')";
                    obj1.InsertRecord(sql1);
                }
                SqlDtr2.Close();
                CreateLogFiles.ErrorLog("Form:Credit_Bill.aspx,Class:PetrolPumpClass.cs,Method:Print Bill No." + lblBillNo.Text.ToString() + " Saved. User Id = " + uid);
                MessageBox.Show("Credit Bill Saved");
                reportmaking();
                Print();
                GetNextBillNo();
                checkPrevileges();

                txtDateFrom.Text          = DateTime.Today.Day.ToString() + "/" + DateTime.Today.Month.ToString() + "/" + DateTime.Today.Year.ToString();
                txtDateTO.Text            = DateTime.Today.Day.ToString() + "/" + DateTime.Today.Month.ToString() + "/" + DateTime.Today.Year.ToString();
                DropCustID.SelectedIndex  = 0;
                GridCreditBill.DataSource = null;
                GridCreditBill.DataBind();
            }
            catch (Exception ex)
            {
                CreateLogFiles.ErrorLog("Form:Credit_Bill.aspx,Class:PetrolPumpClass.cs,Method:Print  " + sql1 + "    =====" + ex.Message + "  EXCEPTION  " + uid);
            }
        }
        //This is used to bind the grid.
        public void displayReport()
        {
            try
            {
                PetrolPumpClass obj1 = new PetrolPumpClass();
                TextBox1.Text = DropCustID.SelectedValue.ToString();
                InventoryClass obj = new InventoryClass();
                SqlDataReader  SqlDtr;
                string         sql = "";

                #region Bind DataGrid
                if (DropVehicleNo.SelectedIndex == 0)
                {
                    sql = "select sm.invoice_no, slip_no, invoice_date, vehicle_no, prod_Name+ ' ' +Pack_Type Prod_Name, qty, rate, amount from sales_master sm, sales_details sd, products p where sm.invoice_date between '" + ToMMddYYYY(txtDateFrom.Text) + "' and dateadd(day,1,'" + ToMMddYYYY(txtDateTO.Text) + "') and sm.cust_id in ( select cust_id from customer where cust_name=substring('" + DropCustID.SelectedItem.Value + "',1,charindex(':','" + DropCustID.SelectedItem.Value + "')-1)  and city=substring('" + DropCustID.SelectedItem.Value + "',charindex(':','" + DropCustID.SelectedItem.Value + "')+1,len('" + DropCustID.SelectedItem.Value + "'))) and sm.sales_type = 'credit' and sm.invoice_no = sd.invoice_no and sd.prod_id = p.prod_id";
                }
                else
                {
                    sql = "select sm.invoice_no, slip_no, invoice_date, vehicle_no, prod_Name+ ' ' +Pack_Type Prod_Name, qty, rate, amount from sales_master sm, sales_details sd, products p where sm.invoice_date between '" + ToMMddYYYY(txtDateFrom.Text) + "' and dateadd(day,1,'" + ToMMddYYYY(txtDateTO.Text) + "') and sm.cust_id in ( select cust_id from customer where cust_name=substring('" + DropCustID.SelectedItem.Value + "',1,charindex(':','" + DropCustID.SelectedItem.Value + "')-1)  and city=substring('" + DropCustID.SelectedItem.Value + "',charindex(':','" + DropCustID.SelectedItem.Value + "')+1,len('" + DropCustID.SelectedItem.Value + "'))) and sm.sales_type = 'credit' and sm.invoice_no = sd.invoice_no and sd.prod_id = p.prod_id and Vehicle_No = '" + DropVehicleNo.SelectedItem.Text + "'";
                }

                SqlDtr = obj.GetRecordSet(sql);
                GridCreditBill.DataSource = SqlDtr;
                GridCreditBill.DataBind();
                if (GridCreditBill.Items.Count == 0)
                {
                    MessageBox.Show("Data not available");
                    GridCreditBill.Visible = false;
                }
                else
                {
                    GridCreditBill.Visible = true;
                }

                SqlDtr.Close();
                checkPrevileges();

                #endregion
                CreateLogFiles.ErrorLog("Form:Credit_Bill.aspx,Class:PetrolPumpClass.cs,Method:displayReport()   Credit Bill Viewed for Bill NO  " + lblBillNo.Text.ToString() + "   Userid " + uid);
            }
            catch (Exception ex)
            {
                CreateLogFiles.ErrorLog("Form:Credit_Bill.aspx ,method :displayReport() " + "  Coustmer :" + DropCustID.SelectedValue.ToString() + "     is Selected " + ex.Message + " EXCEPTION " + "  Userid  " + uid);
            }
        }