예제 #1
0
        /// <summary>
        /// This is used to retrieve Fo/oeID in dropdown.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btschid_Click(object sender, System.EventArgs e)
        {
            btnSubmit.Visible = false;
            btnsave.Visible   = false;
            lblschid.Visible  = false;
            //txtDateFrom.Text="";
            //txtDateTo.Text="";
            ListEmpAssigned.Items.Clear();
            Listprodassign.Items.Clear();
            ListEmpAvailable.Enabled  = true;
            DropShiftID.SelectedIndex = 0;
            dropschid.Visible         = true;
            txtschname.Text           = "";
            btnSubmit.Enabled         = false;
            txtrs.Text        = "";
            btnupdate.Visible = true;
            btschid.Visible   = false;
            InventoryClass obj = new InventoryClass();
            SqlDataReader  SqlDtr1;
            string         sql;

            #region Fetch the All Invoice Number and fill in Combo
            dropschid.Items.Clear();
            dropschid.Items.Add("Select");
            //**sql="select distinct foid ,discription from fleetoe_discount order by foid";
            sql     = "select distinct foid ,discription from foe order by foid";
            SqlDtr1 = obj.GetRecordSet(sql);
            while (SqlDtr1.Read())
            {
                //**dropschid.Items.Add(SqlDtr1.GetValue(0).ToString());
                dropschid.Items.Add(SqlDtr1.GetValue(0).ToString() + ':' + SqlDtr1.GetValue(1).ToString());
            }
            SqlDtr1.Close();
            #endregion
        }
        /// <summary>
        /// this is used to fill the id in the dropdown for update the scheme.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btschid_Click(object sender, System.EventArgs e)
        {
            btnSubmit.Visible = false;
            lblschid.Visible  = false;
            ListEmpAssigned.Items.Clear();
            ListEmpAvailable.Enabled = true;
            //DropSchType.SelectedIndex=0;
            dropschid.Visible = true;
            btschid.Visible   = false;
            btnSubmit.Enabled = false;
            btnupdate.Visible = true;
            InventoryClass obj = new InventoryClass();
            SqlDataReader  SqlDtr1;
            string         sql;

            #region Fetch the All Invoice Number and fill in Combo
            dropschid.Items.Clear();
            dropschid.Items.Add("Select");
            sql     = "select distinct sch_id ,schname from StktSchDiscount order by sch_id";
            SqlDtr1 = obj.GetRecordSet(sql);
            while (SqlDtr1.Read())
            {
                dropschid.Items.Add(SqlDtr1.GetValue(0).ToString() + ':' + SqlDtr1.GetValue(1).ToString());
            }
            SqlDtr1.Close();
            #endregion
        }
예제 #3
0
        public IHttpActionResult LedgerName_SelectedIndexChanged(string VoucherId)
        {
            SqlDataReader SqlDtr, SqlDtr1;
            SqlCommand    SqlCmd;
            string        sql, sql2;

            using (SqlCon = new SqlConnection())
            {
                SqlCon = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ServoSMS"]);
                SqlCon.Open();
                sql    = "Select * from payment_transaction where voucher_Id ='" + VoucherId + "' ";
                SqlDtr = obj.GetRecordSet(sql);
                while (SqlDtr.Read())
                {
                    payment.tempPaymentID = SqlDtr.GetValue(0).ToString();
                    payment.txtBankname   = SqlDtr["Bank_Name"].ToString().Trim();
                    payment.txtCheque     = SqlDtr["Cheque_No"].ToString().Trim();
                    payment.txtchkDate    = obj.checkDate(GenUtil.str2DDMMYYYY(obj.trimDate(SqlDtr["cheque_date"].ToString().Trim())));
                    payment.txtAmount     = SqlDtr["Amount1"].ToString().Trim();
                    payment.txtNarrartion = SqlDtr["Narration"].ToString().Trim();
                    payment.txtDate       = GenUtil.str2DDMMYYYY(GenUtil.trimDate(SqlDtr["Entry_Date"].ToString()));
                    payment.Invoice_Date  = SqlDtr["Entry_Date"].ToString();
                    payment.LedgerID      = SqlDtr["Ledger_ID_Dr"].ToString();
                    payment.LedgerID1     = SqlDtr["Ledger_ID_Cr"].ToString();
                    sql2    = "Select Ledger_Name from Ledger_Master where Ledger_ID = " + SqlDtr["Ledger_ID_Cr"].ToString().Trim();
                    SqlCmd  = new SqlCommand(sql2, SqlCon);
                    SqlDtr1 = SqlCmd.ExecuteReader();
                    if (SqlDtr1.Read())
                    {
                        payment.CheckCashMode = SqlDtr1["Ledger_Name"].ToString();
                    }
                    SqlDtr1.Close();
                }
                SqlDtr.Close();
            }
            if (payment.Equals(0) || payment == null)
            {
                return(Content(HttpStatusCode.NotFound, "Ledger Name Not Found"));
            }
            return(Ok(payment));
        }
예제 #4
0
    public void GetCustomerInfo()
    {
        try
        {
            InventoryClass obj = new InventoryClass();
            SqlDataReader  SqlDtr, SqlDtr1;

            sql    = "select c.City,CR_Days,Curr_Credit,Cust_ID,Cust_Name,Emp_Name from Customer c,Employee e, customertype ct where e.Emp_ID = c.SSR and Cust_Name = '" + Cust_name + "' and c.cust_type = ct.customertypename order by Cust_Name";
            SqlDtr = obj.GetRecordSet(sql);
            while (SqlDtr.Read())
            {
                Place = SqlDtr.GetValue(0).ToString();

                CrDays  = SqlDtr.GetValue(1).ToString();
                duedate = DateTime.Now.AddDays(System.Convert.ToDouble(SqlDtr["CR_Days"]));


                CrLimit = SqlDtr.GetValue(2).ToString();
                CustID  = SqlDtr.GetValue(3).ToString();

                UnderSalesMan = SqlDtr.GetValue(5).ToString();
                SqlDtr.Close();

                sql1    = "select top 1 Balance,BalanceType from customerledgertable where CustID='" + CustID + "' order by EntryDate Desc";
                SqlDtr1 = obj.GetRecordSet(sql1);
                while (SqlDtr1.Read())
                {
                    CurrBal = SqlDtr1.GetValue(0).ToString() + " " + SqlDtr1.GetValue(1).ToString();
                }
                SqlDtr1.Close();
                break;
            }
        }
        catch (Exception ex)
        {
            throw;
        }
    }
예제 #5
0
        /// <summary>
        /// This method is used for setting the Session variable for userId and
        /// after that filling the required dropdowns with database values
        /// and also check accessing priviledges for particular user
        /// and generate the next ID also.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                uid = (Session["User_Name"].ToString());
                if (!Page.IsPostBack)
                {
                    fillID();
                    btnselect.Visible         = false;
                    btndelete.Enabled         = false;
                    btnadd.Enabled            = true;
                    btnedit.Enabled           = true;
                    droptype.SelectedIndex    = 0;
                    dropregcust.SelectedIndex = 0;

                    SqlCommand    cmd;
                    SqlConnection con;
                    con = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["Servosms"]);
                    con.Open();
                    SqlDataReader SqlDtr1;
                    cmd     = new SqlCommand("select * from CustomerType order by CustomerTypeName", con);
                    SqlDtr1 = cmd.ExecuteReader();

                    droptype.Items.Clear();
                    droptype.Items.Add("Select");
                    if (SqlDtr1.HasRows)
                    {
                        while (SqlDtr1.Read())
                        {
                            droptype.Items.Add(SqlDtr1.GetValue(1).ToString());
                        }
                    }
                    con.Close();
                    SqlDtr1.Close();
                    cmd.Dispose();
                    con.Open();
                    //SqlDataReader SqlDtr1;
                    cmd     = new SqlCommand("select city from Beat_Master order by city", con);
                    SqlDtr1 = cmd.ExecuteReader();

                    dropplace.Items.Clear();
                    dropplace.Items.Add("Select");
                    if (SqlDtr1.HasRows)
                    {
                        while (SqlDtr1.Read())
                        {
                            dropplace.Items.Add(SqlDtr1.GetValue(0).ToString());
                        }
                    }
                    con.Close();
                    SqlDtr1.Close();
                    cmd.Dispose();
                    #region Check Privileges
                    int    i;
                    string View_Flag = "0", Add_Flag = "0", Edit_Flag = "0", Del_Flag = "0";
                    string Module    = "3";
                    string SubModule = "9";
                    string[,] Priv = (string[, ])Session["Privileges"];
                    for (i = 0; i < Priv.GetLength(0); i++)
                    {
                        if (Priv[i, 0] == Module && Priv[i, 1] == SubModule)
                        {
                            View_Flag = Priv[i, 2];
                            Add_Flag  = Priv[i, 3];
                            Edit_Flag = Priv[i, 4];
                            Del_Flag  = Priv[i, 5];

                            break;
                        }
                    }
                    Cache["Add"]  = Add_Flag;
                    Cache["View"] = View_Flag;
                    Cache["Edit"] = Edit_Flag;
                    Cache["Del"]  = Del_Flag;
                    if (View_Flag == "0")
                    {
                        Response.Redirect("../../Sysitem/AccessDeny.aspx", false);
                    }
                    if (Add_Flag == "0")
                    {
                        btnadd.Enabled = false;
                    }
                    if (Edit_Flag == "0")
                    {
                        btnedit.Enabled = false;
                    }
                    if (Del_Flag == "0")
                    {
                        btndelete.Enabled = false;
                    }
                    #endregion
                    CreateLogFiles.ErrorLog("Form:MarketCustEntry.aspx,Method:pageload, Userid=" + uid);
                }
            }
            catch (Exception ex)
            {
                CreateLogFiles.ErrorLog("Form:MarketCustEntry.aspx,Method:pageload" + "  EXCEPTION " + ex.Message + "Userid= " + uid);
            }
        }
예제 #6
0
        /// <summary>
        /// Put user code to initialize the page here
        /// This method is used for setting the Session variable for userId and
        /// after that filling the required dropdowns with database values and also fill some
        /// additional information and also check accessing priviledges for particular user
        /// and generate the next ID also.
        /// and also fatch the customer information according to select customer ID in comes from url.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                uid = (Session["User_Name"].ToString());
            }
            catch (Exception ex)
            {
                CreateLogFiles.ErrorLog("Form:Customer_Update.aspx,Method:on_pageload,Class:PartiesClass.cs " + "EXCEPTION  " + ex.Message + "  " + uid);
                Response.Redirect("../../Sysitem/ErrorPage.aspx", false);
                return;
            }
            if (!Page.IsPostBack)
            {
                try
                {
                    //*************
                    SqlCommand    cmd;
                    SqlConnection con;
                    con = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["Servosms"]);
                    con.Open();
                    SqlDataReader SqlDtr1;
                    cmd     = new SqlCommand("select * from CustomerType order by CustomerTypeName", con);
                    SqlDtr1 = cmd.ExecuteReader();
                    DropCustType.Items.Clear();
                    DropCustType.Items.Add("SELECT");
                    if (SqlDtr1.HasRows)
                    {
                        while (SqlDtr1.Read())
                        {
                            DropCustType.Items.Add(SqlDtr1.GetValue(1).ToString());
                        }
                    }
                    con.Close();
                    SqlDtr1.Close();
                    cmd.Dispose();
                    getbeat();
                    //********
                    #region Check Privileges
                    int    i;
                    string View_flag = "0", Add_Flag = "0", Edit_Flag = "0", Del_Flag = "0";
                    string Module    = "3";
                    string SubModule = "2";
                    string[,] Priv = (string[, ])Session["Privileges"];
                    for (i = 0; i < Priv.GetLength(0); i++)
                    {
                        if (Priv[i, 0] == Module && Priv[i, 1] == SubModule)
                        {
                            View_flag = Priv[i, 2];
                            Add_Flag  = Priv[i, 3];
                            Edit_Flag = Priv[i, 4];
                            Del_Flag  = Priv[i, 5];
                            break;
                        }
                    }
                    if (View_flag == "0")
                    {
                        Response.Redirect("../../Sysitem/AccessDeny.aspx", false);
                    }
                    if (Edit_Flag == "0")
                    {
                        btnUpdate.Enabled = false;
                    }
                    #endregion

                    for (i = 1; i <= 30; i++)
                    {
                        DropCrDay.Items.Add(i.ToString());
                    }

                    LblCustomerID.Text = Request.QueryString.Get("ID");
                    PartiesClass  obj  = new PartiesClass();
                    PartiesClass  obj1 = new PartiesClass();
                    SqlDataReader SqlDtr;
                    string        sql;

                    #region Fetch Extra Cities from Database and add to the ComboBox
                    sql    = "select City from Beat_Master order by city";
                    SqlDtr = obj.GetRecordSet(sql);
                    while (SqlDtr.Read())
                    {
                        DropCity.Items.Add(SqlDtr.GetValue(0).ToString());
                    }
                    SqlDtr.Close();
                    sql    = "select distinct State from Beat_Master";
                    SqlDtr = obj.GetRecordSet(sql);
                    while (SqlDtr.Read())
                    {
                        DropState.Items.Add(SqlDtr.GetValue(0).ToString());
                    }
                    SqlDtr.Close();
                    sql    = "select distinct Country from Beat_Master";
                    SqlDtr = obj.GetRecordSet(sql);
                    while (SqlDtr.Read())
                    {
                        DropCountry.Items.Add(SqlDtr.GetValue(0).ToString());
                    }
                    SqlDtr.Close();
                    #endregion

                    #region Fetch SSR Employee from Employee Table and add to the ComboBox
                    sql    = "select Emp_Name from Employee where Designation='Servo Sales Representative' and status=1 order by Emp_Name";
                    SqlDtr = obj.GetRecordSet(sql);
                    DropSSR.Items.Clear();
                    DropSSR.Items.Add("Select");
                    while (SqlDtr.Read())
                    {
                        DropSSR.Items.Add(SqlDtr.GetValue(0).ToString());
                    }
                    SqlDtr.Close();
                    #endregion

                    #region Fatch the Customer information according to Customer ID and fill the textboxes and dropdownlist
                    SqlDtr = obj.CustomerList(LblCustomerID.Text.ToString(), "", "");
                    while (SqlDtr.Read())
                    {
                        lblName.Text               = SqlDtr.GetValue(1).ToString();
                        TempCustName.Text          = SqlDtr.GetValue(1).ToString();
                        DropCustType.SelectedIndex = DropCustType.Items.IndexOf(DropCustType.Items.FindByValue(SqlDtr.GetValue(2).ToString()));
                        txtAddress.Text            = SqlDtr.GetValue(3).ToString();
                        DropCity.SelectedIndex     = DropCity.Items.IndexOf(DropCity.Items.FindByValue(SqlDtr.GetValue(4).ToString()));
                        DropState.SelectedIndex    = DropState.Items.IndexOf(DropState.Items.FindByValue(SqlDtr.GetValue(5).ToString()));
                        DropCountry.SelectedIndex  = DropCountry.Items.IndexOf(DropCountry.Items.FindByValue(SqlDtr.GetValue(6).ToString()));
                        if (SqlDtr.GetValue(7).ToString().Equals("0"))
                        {
                            txtPhoneRes.Text = "";
                        }
                        else
                        {
                            txtPhoneRes.Text = SqlDtr.GetValue(7).ToString();
                        }

                        if (SqlDtr.GetValue(8).ToString().Equals("0"))
                        {
                            txtPhoneOff.Text = "";
                        }
                        else
                        {
                            txtPhoneOff.Text = SqlDtr.GetValue(8).ToString();
                        }

                        if (SqlDtr.GetValue(9).ToString().Equals("0"))
                        {
                            txtMobile.Text = "";
                        }
                        else
                        {
                            txtMobile.Text = SqlDtr.GetValue(9).ToString();
                        }

                        txtEMail.Text           = SqlDtr.GetValue(10).ToString();
                        txtCRLimit.Text         = SqlDtr.GetValue(11).ToString();
                        DropCrDay.SelectedIndex = DropCrDay.Items.IndexOf(DropCrDay.Items.FindByValue(SqlDtr.GetValue(12).ToString()));
                        if (SqlDtr["SSR"].ToString() != "" && SqlDtr["SSR"].ToString() != null)
                        {
                            SqlDtr1 = obj1.GetRecordSet("select Emp_Name from Employee where Emp_ID='" + SqlDtr["SSR"].ToString() + "'");
                            if (SqlDtr1.Read())
                            {
                                DropSSR.SelectedIndex = DropSSR.Items.IndexOf(DropSSR.Items.FindByValue(SqlDtr1["Emp_Name"].ToString()));
                            }
                            else
                            {
                                DropSSR.SelectedIndex = 0;
                            }
                            SqlDtr1.Close();
                        }
                        else
                        {
                            DropSSR.SelectedIndex = 0;
                        }
                        txtOpBalance.Text     = SqlDtr.GetValue(13).ToString();
                        DropBal.SelectedIndex = DropBal.Items.IndexOf(DropBal.Items.FindByValue(SqlDtr.GetValue(14).ToString()));
                        txtTinNo.Text         = SqlDtr.GetValue(15).ToString().Trim();
                        txtcode.Text          = SqlDtr.GetValue(17).ToString().Trim();
                        txtContactPerson.Text = SqlDtr["ContactPerson"].ToString();
                    }
                    SqlDtr.Close();
                    #endregion
                }
                catch (Exception ex)
                {
                    CreateLogFiles.ErrorLog("Form:Customer_Update.aspx,Method:on_pageload,Class:PartiesClass.cs " + "EXCEPTION  " + ex.Message + "  " + uid);
                }
            }
        }
        /// <summary>
        /// This method is used to view the report.
        /// </summary>
        protected void btnShow_Click(object sender, System.EventArgs e)
        {
            try
            {
                var dt1 = System.Convert.ToDateTime(GenUtil.str2DDMMYYYY(Request.Form["txtDateFrom"].ToString()));
                var dt2 = System.Convert.ToDateTime(GenUtil.str2DDMMYYYY(Request.Form["TextBox1"].ToString()));
                if (DateTime.Compare(dt1, dt2) > 0)
                {
                    MessageBox.Show("Date From Should be less than Date To");
                }
                else
                {
                    Pre_Discount();      //Add by vikas 14.08.09

                    double tradetotal  = 0;
                    double ebirdtotal  = 0;
                    double schemetotal = 0;
                    double fleettotal  = 0;
                    double oetotal     = 0;
                    double totalsalltr = 0;
                    double totalpurltr = 0;


                    //*****************
                    InventoryClass obj = new InventoryClass();
                    SqlDataReader  SqlDtr;
                    //SqlDataReader SqlDtr1;
                    //string sql;
                    string sql1;
                    //SqlDataReader rdr;

                    //cast(floor(cast(Invoice_date as float)) as datetime) >= '"+GenUtil.str2MMDDYYYY(txtDateFrom.Text.Trim())+"' and cast(floor(cast(invoice_date as float)) as datetime) <= '"+GenUtil.str2MMDDYYYY(txtDateTo.Text.Trim()) +"'";
                    sql1 = "select * from Purchase_master  where cast(floor(cast(Invoice_date as float)) as datetime) >= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["txtDateFrom"].ToString()) + "',103) and cast(floor(cast(invoice_date as float)) as datetime) <= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["TextBox1"].ToString()) + "',103)";
                    //sql="select  from Purchase_master  where  cast(floor(cast(vndr_invoice_date as float)) as datetime) <= '"+GenUtil.str2MMDDYYYY(txtDateFrom.Text.Trim())+"' and cast(floor(cast(vndr_invoice_date as float)) as datetime) >= '"+GenUtil.str2MMDDYYYY(TextBox1.Text.Trim()) +"'";
                    SqlDtr = obj.GetRecordSet(sql1);
                    if (SqlDtr.HasRows)
                    {
                        while (SqlDtr.Read())
                        {
                            discountpurchase(SqlDtr.GetValue(0).ToString());
                            tradetotal  += System.Convert.ToDouble(SqlDtr.GetValue(19).ToString());
                            ebirdtotal  += System.Convert.ToDouble(SqlDtr.GetValue(21).ToString());
                            totalpurltr += System.Convert.ToDouble(SqlDtr.GetValue(28).ToString());
                        }
                    }
                    else
                    {
                        Cache["focDisctotal"]   = "0";
                        Cache["fixedDisctotal"] = "0";
                        Cache["CashDisctotal"]  = "0";
                    }
                    //*********************
                    //txttotalpurltr.Text=totalpurltr.ToString();
                    //totalpurltr=Math.Round(totalpurltr,2);
                    lbltotalpurltr.Text = GenUtil.strNumericFormat(totalpurltr.ToString());
                    //txttrade.Text=tradetotal.ToString();
                    //tradetotal=Math.Round(tradetotal,2);
                    lbltrade.Text = GenUtil.strNumericFormat(tradetotal.ToString());
                    //txtebird.Text=ebirdtotal.ToString();
                    //ebirdtotal=Math.Round(ebirdtotal,2);
                    lblebird.Text = GenUtil.strNumericFormat(ebirdtotal.ToString());
                    //				txtfoc.Text=Cache["focDisctotal"].ToString();
                    //				txtfixed.Text=Cache["fixedDisctotal"].ToString();
                    //				txtcash.Text=Cache["CashDisctotal"].ToString();
                    //				double s1=	System.Convert.ToDouble(txtfoc.Text.ToString())+System.Convert.ToDouble(txtfixed.Text.ToString())+System.Convert.ToDouble(txtcash.Text.ToString())+tradetotal+ebirdtotal;
                    lblfoc.Text   = Cache["focDisctotal"].ToString();
                    lblfixed.Text = Cache["fixedDisctotal"].ToString();
                    lblcash.Text  = Cache["CashDisctotal"].ToString();



                    SqlDtr.Close();
                    //********************

                    SqlDataReader SqlDtr1;
                    string        sql3;
                    string        sql2;
                    SqlDataReader rdr = null;
                    //SqlDataReader rdr;
                    //*********************************
                    //sql2="select sum(total_qty*sales*o.discount) from products p,oilscheme o,stock_master ss where ss.productid=p.prod_id and ss.productid=o.prodid and schname='Secondry(LTR Scheme)' and cast(floor(cast(stock_date as float)) as datetime) >= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["txtDateFrom"].ToString()) + "',103) and cast(floor(cast(stock_date as float)) as datetime) <= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["TextBox1"].ToString()) + "',103) and cast(floor(cast(datefrom as float)) as datetime) >= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["txtDateFrom"].ToString()) + "',103) and cast(floor(cast(dateto as float)) as datetime) <= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["TextBox1"].ToString()) + "',103)";
                    sql2    = "select sum(schdiscount) from sales_master where cast(floor(cast(invoice_date as float)) as datetime) >= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["txtDateFrom"].ToString()) + "',103) and cast(floor(cast(invoice_date as float)) as datetime) <= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["TextBox1"].ToString()) + "',103)";
                    SqlDtr1 = obj.GetRecordSet(sql2);
                    if (SqlDtr1.Read())
                    {
                        if (SqlDtr1.GetValue(0).ToString() != "" && SqlDtr1.GetValue(0).ToString() != null)
                        {
                            schemetotal = double.Parse(SqlDtr1.GetValue(0).ToString());
                        }
                    }
                    SqlDtr1.Close();
                    //*********************************

                    //**********Add by Vikas Sharma 15.04.09***********************
                    //sql2="select sum(schdiscount) from sales_master where cast(floor(cast(invoice_date as float)) as datetime) >= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["txtDateFrom"].ToString()) + "',103) and cast(floor(cast(invoice_date as float)) as datetime) <= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["TextBox1"].ToString()) + "',103)";

                    sql2 = "select sum((case when discount_type = 'Per' then ((Grand_Total-(case when cash_disc_type = 'Per' then (Grand_Total*Cash_Discount/100) else Cash_Discount end))+VAT_Amount)*Discount/100 else Discount end)) as Disc from Purchase_Master p, Supplier s where s.Supp_ID = p.Vendor_ID and cast(floor(cast(Invoice_date as float)) as datetime) >= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["txtDateFrom"].ToString()) + "',103) and cast(floor(cast(invoice_date as float)) as datetime) <= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["TextBox1"].ToString()) + "',103)";
                    double Old_Disc = 0;
                    SqlDtr1 = obj.GetRecordSet(sql2);
                    if (SqlDtr1.Read())
                    {
                        if (SqlDtr1.GetValue(0).ToString() != "" && SqlDtr1.GetValue(0).ToString() != null)
                        {
                            Old_Disc = double.Parse(SqlDtr1.GetValue(0).ToString());
                        }
                    }
                    SqlDtr1.Close();
                    lblold.Text = GenUtil.strNumericFormat(Old_Disc.ToString());

                    double s1 = System.Convert.ToDouble(lblfoc.Text.ToString()) + System.Convert.ToDouble(lblfixed.Text.ToString()) + System.Convert.ToDouble(lblcash.Text.ToString()) + tradetotal + ebirdtotal + Old_Disc;
                    s1 = Math.Round(s1, 2);
                    lblpurtotal.Text = s1.ToString();
                    //**********end*************************************************

                    //cast(floor(cast(Invoice_date as float)) as datetime) >= '"+GenUtil.str2MMDDYYYY(txtDateFrom.Text.Trim())+"' and cast(floor(cast(invoice_date as float)) as datetime) <= '"+GenUtil.str2MMDDYYYY(txtDateTo.Text.Trim()) +"'";
                    sql2 = "select * from sales_master  where cast(floor(cast(Invoice_date as float)) as datetime) >= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["txtDateFrom"].ToString()) + "',103) and cast(floor(cast(invoice_date as float)) as datetime) <= Convert(datetime,'" + GenUtil.str2DDMMYYYY(Request.Form["TextBox1"].ToString()) + "',103)";
                    //sql="select  from Purchase_master  where  cast(floor(cast(vndr_invoice_date as float)) as datetime) <= '"+GenUtil.str2MMDDYYYY(txtDateFrom.Text.Trim())+"' and cast(floor(cast(vndr_invoice_date as float)) as datetime) >= '"+GenUtil.str2MMDDYYYY(TextBox1.Text.Trim()) +"'";
                    SqlDtr1 = obj.GetRecordSet(sql2);
                    if (SqlDtr1.HasRows)
                    {
                        while (SqlDtr1.Read())
                        {
                            discountsale(SqlDtr1.GetValue(0).ToString());
                            //schemetotal+=System.Convert.ToDouble(SqlDtr1.GetValue(18).ToString());
                            totalsalltr += System.Convert.ToDouble(SqlDtr1.GetValue(22).ToString());
                            //*********
                            sql3 = "select cust_type from customer  where cust_id='" + SqlDtr1.GetValue(3).ToString() + "'";
                            dbobj.SelectQuery(sql3, ref rdr);
                            if (rdr.Read())
                            {
                                string type = rdr.GetValue(0).ToString();
                                type = type.Substring(0, 2);
                                if (type.ToLower().Equals("fl"))
                                {
                                    fleettotal += System.Convert.ToDouble(SqlDtr1.GetValue(21).ToString());
                                }
                                else if (type.ToLower().Equals("oe"))
                                {
                                    oetotal += System.Convert.ToDouble(SqlDtr1.GetValue(21).ToString());
                                }
                            }
                            // rdr.Close();
                            //******************
                            //**		fleettotal+=System.Convert.ToDouble(SqlDtr1.GetValue(21).ToString());
                        }
                    }
                    else
                    {
                        Cache["saleCashDisctotal"] = "0";
                    }
                    //SqlDtr1.Close();
                    //*********************

                    //				txtoesale.Text=oetotal.ToString();
                    //				txtfleetsale.Text=fleettotal.ToString();
                    //				txtsecsale.Text=schemetotal.ToString();
                    //				//txtdiscountsale.Text=Cache["saleDisctotal"].ToString();
                    //				txtcashsale.Text=Cache["saleCashDisctotal"].ToString();
                    //				double s2=	System.Convert.ToDouble(txtfleetsale.Text.ToString())+System.Convert.ToDouble(txtoesale.Text.ToString())+System.Convert.ToDouble(txtsecsale.Text.ToString())+System.Convert.ToDouble(txtcashsale.Text.ToString());
                    //				txtsaletotal.Text=s2.ToString();
                    //totalsalltr=Math.Round(totalsalltr,2);
                    lbltotalsalltr.Text = GenUtil.strNumericFormat(totalsalltr.ToString());
                    //oetotal=Math.Round(oetotal,2);
                    lbloesale.Text = GenUtil.strNumericFormat(oetotal.ToString());
                    //fleettotal=Math.Round(fleettotal,2);
                    lblfleetsale.Text = GenUtil.strNumericFormat(fleettotal.ToString());
                    //schemetotal=Math.Round(schemetotal,2);
                    lblsecsale.Text = GenUtil.strNumericFormat(schemetotal.ToString());
                    //txtdiscountsale.Text=Cache["saleDisctotal"].ToString();
                    lblcashsale.Text = Cache["saleCashDisctotal"].ToString();
                    if (lblcashsale.Text != "")
                    {
                        lblcashsale.Text = System.Convert.ToString(Math.Round(double.Parse(lblcashsale.Text), 2));
                    }

                    //Coment by vikas 14.08.09 double s2=	System.Convert.ToDouble(lblfleetsale.Text.ToString())+System.Convert.ToDouble(lbloesale.Text.ToString())+System.Convert.ToDouble(lblsecsale.Text.ToString())+System.Convert.ToDouble(lblcashsale.Text.ToString());

                    double s2 = System.Convert.ToDouble(lblfleetsale.Text.ToString()) + System.Convert.ToDouble(lbloesale.Text.ToString()) + System.Convert.ToDouble(lblsecsale.Text.ToString()) + System.Convert.ToDouble(lblcashsale.Text.ToString()) + System.Convert.ToDouble(lblperdis.Text.ToString());

                    //s2=Math.Round(s2,2);
                    lblsaletotal.Text = GenUtil.strNumericFormat(s2.ToString());
                    //**********************
                    CreateLogFiles.ErrorLog("Form:PrimSecDiscount.aspx,Method:btnShow_Click  PrimSecDiscount   Viewed " + "  userid  " + uid);
                }
            }
            catch (Exception ex)
            {
                CreateLogFiles.ErrorLog("Form:PrimSecDiscount.aspx,Method:btnShow_Click  PrimSecDiscount   Viewed " + "  EXCEPTION  " + ex.Message + "  userid  " + uid);
            }
        }