protected void LinkBtnExportExcel_Click(object sender, EventArgs e)
        {
            try
            {
                System.Threading.Thread.Sleep(2000);
                Response.Clear();
                Response.Buffer = true;
                Response.ClearContent();
                Response.ClearHeaders();
                Response.Charset = "";
                string         FileName       = "StockList.xls";
                StringWriter   strwritter     = new StringWriter();
                HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter);
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.ContentType = "application/vnd.ms-excel";
                Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName);

                GVDIff.GridLines             = GridLines.Both;
                GVDIff.HeaderStyle.Font.Bold = true;

                GVDIff.RenderControl(htmltextwrtter);

                Response.Write(strwritter.ToString());
                Response.End();
            }
            catch (Exception ex)
            {
                throw;
                //ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true);
                //lblalert.Text = ex.Message;
            }
        }
        public void FillGrid(string mpurid, string dat)
        {
            try
            {
                //q = " select * from  v_diffRat  where MPurDate <= '" + dat + "' and MPurID ='" + mpurid + "' and  CompanyId = '" + Session["CompanyID"] + "' and BranchId= '" + Session["BranchID"] + "'";
                dt_ = new DataTable();
                //dt_ = DBConnection.GetQueryData(q);
                using (var cmd = new SqlCommand("sp_currdiff", con))
                    using (var da = new SqlDataAdapter(cmd))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@MPurID", PURID.Trim());
                        da.Fill(dt_);
                    }

                if (dt_.Rows.Count > 0)
                {
                    GVDIff.DataSource = dt_;
                    GVDIff.DataBind();

                    lbl_dat.Text     = dt_.Rows[0]["MPurDate"].ToString();
                    lbl_trans.Text   = dt_.Rows[0]["Transport"].ToString();
                    lblotheramt.Text = dt_.Rows[0]["Otheramt"].ToString();
                    lbl_exchrat.Text = dt_.Rows[0]["Exchange_Rat"].ToString();

                    // Rate in PK

                    //GTotal = 0;

                    //for (int j = 0; j < GVDIff.Rows.Count; j++)
                    //{
                    //    Label total = (Label)GVDIff.Rows[j].FindControl("lb_ratinpk");
                    //    GTotal += Convert.ToSingle(total.Text);
                    //}


                    // Rate in Other Currencies

                    //GTotal = 0;

                    //for (int j = 0; j < GVDIff.Rows.Count; j++)
                    //{
                    //    Label total = (Label)GVDIff.Rows[j].FindControl("lb_purpric");
                    //    GTotal += Convert.ToSingle(total.Text);
                    //}
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public void FillGrid(string mpurid, string dat)
        {
            try
            {
                q   = " select * from  v_diffRat  where MPurDate <= '" + dat + "' and MPurID ='" + mpurid + "' and  CompanyId = '" + Session["CompanyID"] + "' and BranchId= '" + Session["BranchID"] + "'";
                dt_ = new DataTable();
                dt_ = DBConnection.GetQueryData(q);

                if (dt_.Rows.Count > 0)
                {
                    GVDIff.DataSource = dt_;
                    GVDIff.DataBind();

                    lbl_dat.Text     = dt_.Rows[0]["MPurDate"].ToString();
                    lbl_trans.Text   = dt_.Rows[0]["Transport"].ToString();
                    lblotheramt.Text = dt_.Rows[0]["Otheramt"].ToString();
                    lbl_exchrat.Text = dt_.Rows[0]["Exchange_Rat"].ToString();

                    // Rate in PK

                    //GTotal = 0;

                    //for (int j = 0; j < GVDIff.Rows.Count; j++)
                    //{
                    //    Label total = (Label)GVDIff.Rows[j].FindControl("lb_ratinpk");
                    //    GTotal += Convert.ToSingle(total.Text);
                    //}


                    // Rate in Other Currencies

                    //GTotal = 0;

                    //for (int j = 0; j < GVDIff.Rows.Count; j++)
                    //{
                    //    Label total = (Label)GVDIff.Rows[j].FindControl("lb_purpric");
                    //    GTotal += Convert.ToSingle(total.Text);
                    //}
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        public void FillGrid(string dat)
        {
            try
            {
                q = " select * from  v_diffRat  where MPurDate = '" + dat + "' and CompanyId = '" + Session["CompanyID"] + "' and BranchId= '" + Session["BranchID"] + "'";

                dt_ = new DataTable();
                dt_ = DBConnection.GetQueryData(q);

                if (dt_.Rows.Count > 0)
                {
                    GVDIff.DataSource = dt_;
                    GVDIff.DataBind();

                    lbl_dat.Text = dt_.Rows[0]["MPurDate"].ToString();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void FillGrid(string dat)
        {
            try
            {
                using (var cmd = new SqlCommand("sp_currdiff", con))
                    using (var da = new SqlDataAdapter(cmd))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@MPurID", PURID.Trim());
                        da.Fill(dt_);
                    }

                if (dt_.Rows.Count > 0)
                {
                    GVDIff.DataSource = dt_;
                    GVDIff.DataBind();
                }

                //q = " select * from  v_diffRat  where MPurDate = '" + dat + "' and CompanyId = '" + Session["CompanyID"] + "' and BranchId= '" + Session["BranchID"] + "'";

                //dt_ = new DataTable();
                //dt_ = DBConnection.GetQueryData(q);

                //if (dt_.Rows.Count > 0)
                //{
                //    GVDIff.DataSource = dt_;
                //    GVDIff.DataBind();

                //    lbl_dat.Text = dt_.Rows[0]["MPurDate"].ToString();
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }