public void BindReportGrid(string RepCondition)
 {
     try
     {
         DataSet DsReport = new DataSet();
         DsReport = Obj_MaterialInwardReg.GetInwordReport(RepCondition, out StrError);
         if (DsReport.Tables.Count > 0 && DsReport.Tables[0].Rows.Count > 0)
         {
             if (!FlagPrint)
             {
                 ImgBtnPrint.Visible = true;
             }
             if (!FlagPrint)
             {
                 ImgBtnExport.Visible = true;
             }
             GridInword.DataSource = DsReport.Tables[0];
             GridInword.DataBind();
             lblCount.Text    = DsReport.Tables[0].Rows.Count + " Records Found";
             lblCount.Visible = true;
         }
         else
         {
             GridInword.DataSource = null;
             GridInword.DataBind();
             lblCount.Text    = DsReport.Tables[0].Rows.Count + " Records Found";
             lblCount.Visible = true;
             SetInitialRow();
         }
     }
     catch (Exception ex) { throw new Exception(ex.Message); }
 }
    protected void ImgBtnExport_Click(object sender, ImageClickEventArgs e)
    {
        DataSet DsGrd = new DataSet();

        StrCondition = string.Empty;
        try
        {
            if (Convert.ToInt32(RdoType.SelectedValue) != 2)
            {
                StrCondition = StrCondition + " and QM.InwardThrough=" + Convert.ToInt32(RdoType.SelectedValue);
            }
            if (Convert.ToInt32(ddlInwardNo.SelectedValue) > 0)
            {
                StrCondition = StrCondition + " and QM.InwardId=" + Convert.ToInt32(ddlInwardNo.SelectedValue);
            }

            if (!string.IsNullOrEmpty(ddlSuppName.Text) && Convert.ToInt32(ddlSuppName.SelectedValue) > 0)
            {
                StrCondition = StrCondition + " and QM.SuplierId=" + Convert.ToInt32(ddlSuppName.SelectedValue);
            }
            if (ChkFrmDate.Checked == true)
            {
                StrCondition = StrCondition + " and QM.InwardDate between '" + Convert.ToDateTime(txtFromDate.Text).ToString("MM-dd-yyyy") + "' AND '" + Convert.ToDateTime(txtToDate.Text).ToString("MM-dd-yyyy") + "' ";
            }
            else
            {
                StrCondition = StrCondition + " AND QM.InwardDate between '01-01-1975' AND '" + DateTime.Now.ToString("MM-dd-yyyy") + "' ";
            }
            // //if (!Convert.ToBoolean(Session["IsCentral"].ToString()))
            // //{
            //     StrCondition = StrCondition + " AND QM.Location=" + Convert.ToInt32(Session["CafeteriaId"].ToString());
            //// }
            DsGrd = Obj_MaterialInwardReg.GetInwordReport(StrCondition, out StrError);

            if (DsGrd.Tables[0].Rows.Count > 0)
            {
                //========Call Register
                GridView GridExp = new GridView();
                GridExp.DataSource = DsGrd.Tables[0];
                GridExp.DataBind();
                obj_Comman.Export("InwardRegisterList.xls", GridExp);
            }
            else
            {
                obj_Comman.ShowPopUpMsg("No Data Found To Export..!", this.Page);
                DsGrd.Dispose();
                GridInword.DataSource = null;
                GridInword.DataBind();
            }
        }
        catch (ThreadAbortException tex)
        {
        }
        catch (Exception ex)
        {
        }
    }
    public void SetInitialRow()
    {
        try
        {
            DataTable dt = new DataTable();
            DataRow   dr = null;
            dt.Columns.Add(new DataColumn("#", typeof(int)));
            dt.Columns.Add(new DataColumn("InwardNo", typeof(string)));
            dt.Columns.Add(new DataColumn("InwardDate", typeof(string)));
            dt.Columns.Add(new DataColumn("PONO", typeof(string)));
            dt.Columns.Add(new DataColumn("type", typeof(string)));
            dt.Columns.Add(new DataColumn("SuplierName", typeof(string)));
            dt.Columns.Add(new DataColumn("SubTotal", typeof(decimal)));
            dt.Columns.Add(new DataColumn("Discount", typeof(decimal)));
            dt.Columns.Add(new DataColumn("Vat", typeof(decimal)));
            dt.Columns.Add(new DataColumn("DekhrekhAmt", typeof(decimal)));
            dt.Columns.Add(new DataColumn("HamaliAmt", typeof(decimal)));
            dt.Columns.Add(new DataColumn("CESSAmt", typeof(decimal)));
            dt.Columns.Add(new DataColumn("FreightAmt", typeof(decimal)));
            dt.Columns.Add(new DataColumn("PackingAmt", typeof(decimal)));
            dt.Columns.Add(new DataColumn("PostageAmt", typeof(decimal)));
            dt.Columns.Add(new DataColumn("OtherCharges", typeof(decimal)));

            dt.Columns.Add(new DataColumn("GrandTotal", typeof(decimal)));

            dr = dt.NewRow();

            dr["#"]            = 0;
            dr["InwardNo"]     = "";
            dr["InwardDate"]   = "";
            dr["SuplierName"]  = "";
            dr["PONO"]         = "";
            dr["type"]         = "";
            dr["SubTotal"]     = 0;
            dr["Discount"]     = 0;
            dr["Vat"]          = 0;
            dr["DekhrekhAmt"]  = 0;
            dr["HamaliAmt"]    = 0;
            dr["CESSAmt"]      = 0;
            dr["FreightAmt"]   = 0;
            dr["PackingAmt"]   = 0;
            dr["PostageAmt"]   = 0;
            dr["OtherCharges"] = 0;
            dr["GrandTotal"]   = 0;
            dt.Rows.Add(dr);
            ViewState["CurrentTable"] = dt;
            GridInword.DataSource     = dt;
            GridInword.DataBind();
            dt = null;
            dr = null;
        }
        catch (Exception ex)
        {
            throw;
        }
    }
    protected void GridInword_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        try
        {
            this.GridInword.PageIndex = e.NewPageIndex;
            DataSet DsReport = new DataSet();
            StrCondition = string.Empty;
            if (Convert.ToInt32(ddlInwardNo.SelectedValue) > 0)
            {
                StrCondition = StrCondition + " and QM.InwardId=" + Convert.ToInt32(ddlInwardNo.SelectedValue);
            }

            if (!string.IsNullOrEmpty(ddlSuppName.Text) && Convert.ToInt32(ddlSuppName.SelectedValue) > 0)
            {
                StrCondition = StrCondition + " and QM.SuplierId=" + Convert.ToInt32(ddlSuppName.SelectedValue);
            }
            if (ChkFrmDate.Checked == true)
            {
                StrCondition = StrCondition + " and QM.InwardDate between '" + Convert.ToDateTime(txtFromDate.Text).ToString("MM-dd-yyyy") + "' AND '" + Convert.ToDateTime(txtToDate.Text).ToString("MM-dd-yyyy") + "' ";
            }
            else
            {
                StrCondition = StrCondition + " AND QM.InwardDate between '01-01-1975' AND '" + DateTime.Now.ToString("MM-dd-yyyy") + "' ";
            }
            //if (!Convert.ToBoolean(Session["IsCentral"].ToString()))
            //{
            //    StrCondition = StrCondition + " AND QM.Location=" + Convert.ToInt32(Session["CafeteriaId"].ToString());
            //}
            DsReport = Obj_MaterialInwardReg.GetInwordReport(StrCondition, out StrError);
            if (DsReport.Tables.Count > 0 && DsReport.Tables[0].Rows.Count > 0)
            {
                GridInword.DataSource = DsReport.Tables[0];
                GridInword.DataBind();
                lblCount.Text    = DsReport.Tables[0].Rows.Count + " Records Found";
                lblCount.Visible = true;
            }
            else
            {
                GridInword.DataSource = null;
                GridInword.DataBind();
                lblCount.Text    = DsReport.Tables[0].Rows.Count + " Records Found";
                lblCount.Visible = true;
                SetInitialRow();
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }