protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.UrlReferrer == null)
            {
                base.AutoRedirect();
            }
            SessionValues svalue = new SessionValues();

            //  base.UsessionValue = svalue.FetchUsersAndComp(string.IsNullOrEmpty(Convert.ToString(Session["Visageuseridno"])) ? 0 : Convert.ToInt32(Session["Visageuseridno"]));
            // conString = ConfigurationManager.ConnectionStrings["VisageConnectionString"].ToString();
            svalue = null;
            if (!Page.IsPostBack)
            {
                this.Title = "Manage Delivery Register";
                this.BindDateRange();
                ddlDateRange.SelectedIndex = 0;
                ddlDateRange_SelectedIndexChanged(null, null);
                this.BidFromCity();
                ChallanDelverdDAL objChallanDelverdDAL = new ChallanDelverdDAL();
                tblUserPref       obj = objChallanDelverdDAL.selectUserPref();
                ddlTocity.SelectedValue = Convert.ToString(obj.BaseCity_Idno);
                txtDateFrom.Attributes.Add("onkeypress", "return notAllowAnything(event);");
                txtDateTo.Attributes.Add("onkeypress", "return notAllowAnything(event);");
                this.Countall();
                ddlDateRange.Focus();
            }
        }
Ejemplo n.º 2
0
 private void Populate(Int64 MtrlRcptHeadId)
 {
     try
     {
         ChallanDelverdDAL objChallanDelverdDAL = new ChallanDelverdDAL();
         tblChlnDelvHead   objtblChlnDelvHead   = objChallanDelverdDAL.SelectHeadInEdit(MtrlRcptHeadId);
         if (objtblChlnDelvHead != null)
         {
             txtDate.Text = Convert.ToDateTime(objtblChlnDelvHead.ChlnDelv_Date).Date.ToString("dd-MM-yyyy");
             ddlDateRange.SelectedValue = Convert.ToString(objtblChlnDelvHead.Year_Idno);
             ddlToCity.SelectedValue    = Convert.ToString(objtblChlnDelvHead.ToCity_Idno);
             ddlToCity_SelectedIndexChanged(null, null);
             txtRcptNo.Text = objtblChlnDelvHead.ChlnDelv_No.ToString();
             ddlChallanDetl.SelectedValue = objtblChlnDelvHead.ChlnTransf_Idno.ToString();
             hidMtrlRcptid.Value          = objtblChlnDelvHead.ChlnDelvHead_Idno.ToString();
             txtLocGrAmnt.Text            = Convert.ToDouble(objtblChlnDelvHead.LocGR_Amnt).ToString("N2");
             txtoutGrAmnt.Text            = Convert.ToDouble(objtblChlnDelvHead.CrsngGR_Amnt).ToString("N2");
             txtNetAmnt.Text  = Convert.ToDouble(objtblChlnDelvHead.Net_Amnt).ToString("N2");
             lblRcptDtNo.Text = "Receipt Date";
         }
         DataSet Ds = objChallanDelverdDAL.SelectGridDetlInEdit(ApplicationFunction.ConnectionString(), MtrlRcptHeadId);
         objChallanDelverdDAL = null;
         ViewState["dt"]      = (DataTable)Ds.Tables[0];
         grdMain.DataSource   = ViewState["dt"];
         grdMain.DataBind();
     }
     catch (Exception e) { }
 }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SessionValues svalue = new SessionValues();

            //  base.UsessionValue = svalue.FetchUsersAndComp(string.IsNullOrEmpty(Convert.ToString(Session["Visageuseridno"])) ? 0 : Convert.ToInt32(Session["Visageuseridno"]));
            if (Request.UrlReferrer == null)
            {
                base.AutoRedirect();
            }
            if (!Page.IsPostBack)
            {
                if (base.CheckUserRights(intFormId) == false)
                {
                    Response.Redirect("PermissionDenied.aspx");
                }
                if (base.ADD == false)
                {
                    lnkBtnSave.Visible = false;
                }
                if (base.View == false)
                {
                    lblViewList.Visible = false;
                }
                txtDate.Attributes.Add("onkeypress", "return notAllowAnything(event);");
                txtDate.Text = System.DateTime.Now.ToString("dd-MM-yyyy");
                this.BindDateRange();
                ddlDateRange.SelectedValue = Convert.ToString(base.UserDateRng);
                ddlDateRange.SelectedIndex = 0;
                ddlDateRange_SelectedIndexChanged(null, null);
                if (Convert.ToString(Session["Userclass"]) == "Admin")
                {
                    this.BidFromCity();
                }
                else
                {
                    this.BindCity(Convert.ToInt64(Session["UserIdno"]));
                }

                ChallanDelverdDAL objChallanDelverdDAL = new ChallanDelverdDAL();
                tblUserPref       obj = objChallanDelverdDAL.selectUserPref();
                ddlToCity.SelectedValue = Convert.ToString(base.UserFromCity);
                BindChlnNo();
                ViewState["dt"] = null;
                if (Request.QueryString["chlnrcptidno"] != null)
                {
                    lnkSubmit.Visible = false; ddlChallanDetl.Enabled = false; DivRcptNo.Visible = true; txtRcptNo.Visible = true; ddlToCity.Enabled = false;

                    this.Populate(Convert.ToInt32(Request.QueryString["chlnrcptidno"]));
                    this.Title        = "Edit Delivery Challan";
                    lnkBtnNew.Visible = true;
                }
                else
                {
                    lnkSubmit.Visible = true; ddlChallanDetl.Enabled = true; txtRcptNo.Visible = false; DivRcptNo.Visible = false; lblRcptDtNo.Text = "Receipt Date"; ddlToCity.Enabled = true;
                    lnkBtnNew.Visible = false;
                }
                ddlDateRange.Focus();
            }
            svalue = null;
        }
Ejemplo n.º 4
0
        public Int64 MaxRcptHeadNo(int fromcity, int YearIdno)
        {
            ChallanDelverdDAL objMtrlRcptHODAL = new ChallanDelverdDAL();
            Int64             RecHeadNo        = objMtrlRcptHODAL.MaxRcptHeadNo(fromcity, YearIdno);

            objMtrlRcptHODAL = null;
            return(RecHeadNo);
        }
Ejemplo n.º 5
0
        public DateTime MtrlTransfDate(Int64 MtrlTransfIdno)
        {
            DateTime          Value;
            ChallanDelverdDAL objMtrlRcptHODAL = new ChallanDelverdDAL();

            Value            = objMtrlRcptHODAL.MtrlTransfDate(MtrlTransfIdno);
            objMtrlRcptHODAL = null;
            return(Value);
        }
        public void Countall()
        {
            ChallanDelverdDAL obj = new ChallanDelverdDAL();

            Int64 count = obj.Countall();

            if (count > 0)
            {
                lbltotalstaff.Text = "T. Record (s):" + count;
            }
        }
Ejemplo n.º 7
0
        private void BindGrid()
        {
            ChallanDelverdDAL obj         = new ChallanDelverdDAL();
            Int32             iTocityIdno = (drpToCity.SelectedIndex <= 0 ? 0 : Convert.ToInt32(drpToCity.SelectedValue));
            string            UserClass   = Convert.ToString(Session["Userclass"]);
            Int32             UserIdno    = 0;

            if (UserClass != "Admin")
            {
                UserIdno = Convert.ToInt32(Session["UserIdno"]);
            }
            DataSet DsDetl = obj.SearchDelevryRegisterReport(Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateFrom.Text)),
                                                             Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text)), iTocityIdno, Convert.ToInt32(ddlDateRange.SelectedValue), UserIdno, ApplicationFunction.ConnectionString());

            if ((DsDetl != null) && (DsDetl.Tables[0].Rows.Count > 0))
            {
                Double TotalNetAmountLocGRAmnt   = 0;
                Double TotalNetAmountCrsngGRAmnt = 0;
                Double TotalNetAmount            = 0;


                for (int i = 0; i < DsDetl.Tables[0].Rows.Count; i++)
                {
                    TotalNetAmountLocGRAmnt   += Convert.ToDouble(DsDetl.Tables[0].Rows[i]["LocGR_Amnt"]);
                    TotalNetAmountCrsngGRAmnt += Convert.ToDouble(DsDetl.Tables[0].Rows[i]["CrsngGR_Amnt"]);
                    TotalNetAmount            += Convert.ToDouble(DsDetl.Tables[0].Rows[i]["Net_Amnt"]);
                }
                lblNetTotalAmountLocGRAmnt.Text   = TotalNetAmountLocGRAmnt.ToString("N2");
                lblNetTotalAmountCrsngGRAmnt.Text = TotalNetAmountCrsngGRAmnt.ToString("N2");
                lblNetTotalAmount.Text            = TotalNetAmount.ToString("N2");

                ViewState["CSVdt"] = DsDetl.Tables[0];
                grdMain.DataSource = DsDetl.Tables[0];
                grdMain.DataBind();
                imgBtnExcel.Visible = true;
                lblTotalRecord.Text = "Total Record (s): " + DsDetl.Tables[0].Rows.Count;

                int startRowOnPage = (grdMain.PageIndex * grdMain.PageSize) + 1;
                int lastRowOnPage  = startRowOnPage + grdMain.Rows.Count - 1;
                lblcontant.Text    = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + DsDetl.Tables[0].Rows.Count.ToString();
                lblcontant.Visible = true;
                divpaging.Visible  = true;
            }
            else
            {
                grdMain.DataSource = null;
                grdMain.DataBind();
                imgBtnExcel.Visible = false;
                lblTotalRecord.Text = "Total Record (s): 0 ";

                lblcontant.Visible = false;
                divpaging.Visible  = false;
            }
        }
Ejemplo n.º 8
0
        private void BidFromCity()
        {
            ChallanDelverdDAL ObjChallanDelverdDAL = new ChallanDelverdDAL();
            var lst = ObjChallanDelverdDAL.BindFromCity();

            ObjChallanDelverdDAL     = null;
            ddlTocity.DataSource     = lst;
            ddlTocity.DataTextField  = "City_Name";
            ddlTocity.DataValueField = "City_Idno";
            ddlTocity.DataBind();
            ddlTocity.Items.Insert(0, new ListItem("< Select >", "0"));
        }
Ejemplo n.º 9
0
        private void ClearControls()
        {
            lnkBtnNew.Visible         = false;
            txtGrno.Text              = "";
            ddlLocation.SelectedValue = "0";
            grdMain.Visible           = false;
            hidMtrlRcptid.Value       = hidMtrlTrnsfDt.Value = string.Empty;
            lnkSubmit.Visible         = true; ddlLocation.Enabled = true;
            ChallanDelverdDAL objChallanDelverdDAL = new ChallanDelverdDAL();
            tblUserPref       obj = objChallanDelverdDAL.selectUserPref();

            ddlLocation.SelectedValue = Convert.ToString(obj.BaseCity_Idno);
        }
 protected void grdUser_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "cmdEdit")
     {
         Response.Redirect("ChallanDelverd.aspx?chlnrcptidno=" + e.CommandArgument, true);
     }
     else if (e.CommandName == "cmddelete")
     {
         ChallanDelverdDAL objChallanDelverdDAL = new ChallanDelverdDAL();
         long value = objChallanDelverdDAL.DeleteALL(Convert.ToInt64(e.CommandArgument));
         objChallanDelverdDAL = null;
         if (value > 0)
         {
             this.Populate();
         }
     }
 }
Ejemplo n.º 11
0
        private void BindChlnNo()
        {
            Int32             fromCityIdno         = Convert.ToInt32(ddlToCity.SelectedValue);
            ChallanDelverdDAL objChallanDelverdDAL = new ChallanDelverdDAL();
            int Typ = 0;

            if (Request.QueryString["chlnrcptidno"] != null)
            {
                Typ = 1;
            }
            var lst = objChallanDelverdDAL.SelectMatTransfNo(fromCityIdno, Typ, Convert.ToInt32(ddlDateRange.SelectedValue));

            objChallanDelverdDAL          = null;
            ddlChallanDetl.DataSource     = lst;
            ddlChallanDetl.DataTextField  = "Chln_no";
            ddlChallanDetl.DataValueField = "chln_Idno";
            ddlChallanDetl.DataBind();
            ddlChallanDetl.Items.Insert(0, new ListItem("--Select Challan No.--", "0"));
        }
Ejemplo n.º 12
0
        private void ClearControls()
        {
            lnkBtnNew.Visible = false;
            txtLocGrAmnt.Text = "";
            txtoutGrAmnt.Text = "";
            txtNetAmnt.Text   = "";

            ddlToCity.SelectedIndex      = 0;
            ddlChallanDetl.SelectedValue = "0";
            txtRcptNo.Text      = string.Empty;
            hidMtrlRcptid.Value = hidMtrlTrnsfDt.Value = string.Empty;
            grdMain.DataSource  = null;
            grdMain.DataBind();
            ddlToCity.Enabled      = true;
            ddlChallanDetl.Enabled = true;
            lnkSubmit.Visible      = true; ddlChallanDetl.Enabled = true; txtRcptNo.Visible = false; DivRcptNo.Visible = false; lblRcptDtNo.Text = "Receipt Date"; ddlToCity.Enabled = true;
            ChallanDelverdDAL objChallanDelverdDAL = new ChallanDelverdDAL();
            tblUserPref       obj = objChallanDelverdDAL.selectUserPref();

            ddlToCity.SelectedValue = Convert.ToString(obj.BaseCity_Idno);
        }
Ejemplo n.º 13
0
 private void BindGrid()
 {
     if ((ddlChallanDetl.SelectedIndex > 0) && (txtDate.Text.Trim() != ""))
     {
         ChallanDelverdDAL obj = new ChallanDelverdDAL();
         int   rec             = 0;
         Int64 MtrlRcptIdno    = (Convert.ToString(hidMtrlRcptid.Value) != "" ? Convert.ToInt64(hidMtrlRcptid.Value) : 0);
         rec = obj.IsExeistMtrlTransf(Convert.ToInt64(ddlChallanDetl.SelectedValue), Convert.ToInt32(ddlDateRange.SelectedValue), MtrlRcptIdno);
         if (rec > 0)
         {
             grdMain.Visible = false;
             string msg = "Receipt of the transfer no. : " + ddlChallanDetl.SelectedItem.Text + " is already generated.";
             grdMain.DataSource = null;
             grdMain.DataBind();
             ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmsg", "PassMessageError('" + msg + "')", true);
         }
         else
         {
             DateTime dMtrlDt = obj.MtrlTransfDate(Convert.ToInt64(ddlChallanDetl.SelectedValue));
             hidMtrlTrnsfDt.Value = dMtrlDt.ToString("dd-MM-yyyy");
             if (Convert.ToDateTime(ApplicationFunction.mmddyyyy(hidMtrlTrnsfDt.Value)) > Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text)))
             {
                 grdMain.Visible    = false;
                 grdMain.DataSource = null; grdMain.DataBind();
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmsg", "PassMessageError('Date must be Greater than or equal to Transfer Date [" + dMtrlDt.Date.ToString("dd-MMM-yyyy") + "].')", true);
             }
             else
             {
                 DataSet Ds = obj.SelectGridDetl(ApplicationFunction.ConnectionString(), "SelectTransfDetl", Convert.ToInt64(ddlChallanDetl.SelectedValue), Convert.ToInt32(ddlToCity.SelectedValue));
                 obj       = null;
                 LocGrAmnt = 0; OutGrAmnt = 0;
                 if (Ds != null && Ds.Tables[0].Rows.Count > 0)
                 {
                     foreach (DataRow dr in Ds.Tables[0].Rows)
                     {
                         Int32  DelvPlcIdno = Convert.ToInt32(dr["DelvryPlce_Idno"]);
                         double dGrAmnt     = Convert.ToDouble(dr["Amount"]);
                         if (Convert.ToInt32(ddlToCity.SelectedValue) == DelvPlcIdno)
                         {
                             LocGrAmnt += dGrAmnt;
                         }
                         else
                         {
                             OutGrAmnt += dGrAmnt;
                         }
                     }
                 }
                 txtLocGrAmnt.Text  = LocGrAmnt.ToString("N2");
                 txtoutGrAmnt.Text  = OutGrAmnt.ToString("N2");
                 txtNetAmnt.Text    = Convert.ToDouble(LocGrAmnt + OutGrAmnt).ToString("N2");
                 ViewState["dt"]    = (DataTable)Ds.Tables[0];
                 grdMain.DataSource = ViewState["dt"];
                 grdMain.DataBind();
                 grdMain.Visible = true;
             }
         }
         obj = null;
     }
     else
     {
         grdMain.Visible = false;
         ddlChallanDetl.SelectedIndex = 0;
         ddlChallanDetl.Focus();
         grdMain.DataSource = null;
         grdMain.DataBind();
     }
 }
Ejemplo n.º 14
0
        protected void lnkBtnSave_Click(object sender, EventArgs e)
        {
            string msg = string.Empty; bool bflag = false; double IssueQty = 0, IssueWT = 0;

            if (grdMain.Rows.Count <= 0)
            {
                ShowMessage("Please Enter Challan Details");
            }
            else
            {
                DtTemp = (DataTable)ViewState["dt"];
                DtTemp = CreateDt();
                ChallanDelverdDAL objChallanDelverdDAL = new ChallanDelverdDAL();
                Int64             MtrlRcptId = 0, MtrlRcptDetlId = 0;
                string            strMsgTyp = String.Empty;
                int yearIdno = Convert.ToInt32(ddlDateRange.SelectedValue);

                Int64           Value           = 0;
                tblChlnDelvHead ObjMtrlRcptHead = new tblChlnDelvHead();
                ObjMtrlRcptHead.ChlnDelv_Date   = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text));
                ObjMtrlRcptHead.ToCity_Idno     = Convert.ToInt32(ddlToCity.SelectedValue);
                ObjMtrlRcptHead.ChlnTransf_Idno = Convert.ToInt32(ddlChallanDetl.SelectedValue);
                ObjMtrlRcptHead.Date_Added      = ApplicationFunction.GetIndianDateTime().Date; // DateTime.Now.Date;
                ObjMtrlRcptHead.Date_Modified   = ApplicationFunction.GetIndianDateTime().Date;
                ObjMtrlRcptHead.ChlnDelv_No     = MaxRcptHeadNo(Convert.ToInt32(ddlToCity.SelectedValue), Convert.ToInt32(ddlDateRange.SelectedValue));
                ObjMtrlRcptHead.CrsngGR_Amnt    = Convert.ToDouble(txtoutGrAmnt.Text);
                ObjMtrlRcptHead.LocGR_Amnt      = Convert.ToDouble(txtLocGrAmnt.Text);
                ObjMtrlRcptHead.Net_Amnt        = Convert.ToDouble(txtNetAmnt.Text);
                ObjMtrlRcptHead.Year_Idno       = Convert.ToInt32(ddlDateRange.SelectedValue);
                foreach (GridViewRow row in grdMain.Rows)
                {
                    HiddenField hidGrIdno   = (HiddenField)row.FindControl("hidGridno");
                    HiddenField hidItemidno = (HiddenField)row.FindControl("hidItemidno");
                    HiddenField hidUnitidno = (HiddenField)row.FindControl("hidUnitidno");
                    Label       lblrateType = (Label)row.FindControl("lblrateType");
                    Label       lblQty      = (Label)row.FindControl("lblQty");
                    Label       lblWeight   = (Label)row.FindControl("lblWeight");
                    Label       lblAmount   = (Label)row.FindControl("lblAmount");
                    TextBox     txtRecQty   = (TextBox)row.FindControl("txtRecQty");
                    TextBox     txtRecWT    = (TextBox)row.FindControl("txtRecWT");
                    TextBox     txtRecWt    = (TextBox)row.FindControl("txtRecWt");
                    TextBox     txtRemark   = (TextBox)row.FindControl("txtRemark");
                    TextBox     txtRecAmt   = (TextBox)row.FindControl("txtRecAmt");
                    if (lblrateType.Text == "Rate")
                    {
                        if (txtRecQty.Text == "")
                        {
                            ShowMessageErr("Please Enter Receiving QTY!");
                            return;
                        }
                        if (Convert.ToDouble(txtRecQty.Text) < 0.00)
                        {
                            ShowMessageErr("You Cannot Enter Receiving QTY Less than 1!");
                            return;
                        }

                        IssueQty = Convert.ToDouble(lblQty.Text);
                        if (IssueQty < Convert.ToDouble(txtRecQty.Text))
                        {
                            txtRecQty.Focus();
                            txtRecQty.Text = "0.00";
                            ShowMessageErr("You Cannot Enter Receiving QTY more than GR QTY!");
                            return;
                        }
                    }
                    else
                    {
                        if (txtRecWT.Text == "")
                        {
                            ShowMessageErr("Please Enter Receiving Weight!");
                            return;
                        }
                        if (Convert.ToDouble(txtRecWT.Text) < 0.00)
                        {
                            ShowMessageErr("You Cannot Enter Receiving Weight Less than 1!");
                            return;
                        }
                        IssueWT = Convert.ToDouble(lblWeight.Text);
                        if (IssueWT < Convert.ToDouble(txtRecWT.Text))
                        {
                            txtRecWT.Focus(); txtRecWT.Text = "0.00";
                            ShowMessageErr("You Cannot Enter Receiving Weight more than GR Weight!");
                            return;
                        }
                    }
                    ApplicationFunction.DatatableAddRow(DtTemp, hidGrIdno.Value, hidItemidno.Value, hidUnitidno.Value, ((lblrateType.Text) == "Rate") ? "1" : "2", lblQty.Text, lblWeight.Text,
                                                        lblAmount.Text, txtRecQty.Text, txtRecWt.Text, txtRecAmt.Text, txtRemark.Text);
                }
                using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required))
                {
                    try
                    {
                        ChallanDelverdDAL obj     = new ChallanDelverdDAL();
                        DateTime          dMtrlDt = obj.MtrlTransfDate(Convert.ToInt64(ddlChallanDetl.SelectedValue));
                        hidMtrlTrnsfDt.Value = dMtrlDt.ToString("dd-MM-yyyy");
                        if (Convert.ToDateTime(ApplicationFunction.mmddyyyy(hidMtrlTrnsfDt.Value)) > Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text)))
                        {
                            txtDate.Focus();
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmsg", "PassMessageError('Delivery Date must be greater than or equal to Challan Date [" + dMtrlDt.Date.ToString("dd-MMM-yyyy") + "].')", true);
                            return;
                        }
                        if (string.IsNullOrEmpty(hidMtrlRcptid.Value) == true)
                        {
                            MtrlRcptId = obj.InsertMtrlRcptHOHead(ObjMtrlRcptHead, DtTemp);
                            if (MtrlRcptId > 0)
                            {
                                tScope.Complete();
                            }
                        }
                        else
                        {
                            tblChlnDelvHead ObjMtrlRcptHeadU = new tblChlnDelvHead();
                            ObjMtrlRcptHeadU.ChlnDelv_Date   = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text));
                            ObjMtrlRcptHeadU.ToCity_Idno     = Convert.ToInt32(ddlToCity.SelectedValue);
                            ObjMtrlRcptHeadU.ChlnTransf_Idno = Convert.ToInt32(ddlChallanDetl.SelectedValue);
                            ObjMtrlRcptHeadU.Date_Modified   = ApplicationFunction.GetIndianDateTime().Date;
                            ObjMtrlRcptHeadU.CrsngGR_Amnt    = Convert.ToDouble(txtoutGrAmnt.Text);
                            ObjMtrlRcptHeadU.LocGR_Amnt      = Convert.ToDouble(txtLocGrAmnt.Text);
                            ObjMtrlRcptHeadU.Net_Amnt        = Convert.ToDouble(txtNetAmnt.Text);
                            ObjMtrlRcptHeadU.Year_Idno       = Convert.ToInt32(ddlDateRange.SelectedValue);
                            MtrlRcptId = obj.UpdateMtrlRcptHOHead(ObjMtrlRcptHeadU, DtTemp, Convert.ToInt32(hidMtrlRcptid.Value));
                            if ((MtrlRcptId > 0))
                            {
                                tScope.Complete();
                            }
                        }
                    }

                    catch (Exception ex)
                    {
                        // ApplicationFunction.ErrorLog(ex.ToString());
                    }
                }
                if (string.IsNullOrEmpty(hidMtrlRcptid.Value) == true)
                {
                    if (MtrlRcptId > 0)
                    {
                        ShowMessage("Record Saved Successffully");
                    }
                }
                else
                {
                    if ((MtrlRcptId > 0))
                    {
                        ShowMessage("Record Update successfully");
                    }
                }
                if (MtrlRcptId == -1)
                {
                    ShowMessage("Challan No. already  Delivered !");
                    bflag     = false;
                    strMsgTyp = "RecExst";
                    ddlChallanDetl.Focus();
                }
                else
                {
                    ClearControls();
                }
            }
        }
        private void Populate()
        {
            string   action = string.Empty;
            DateTime?dateFrom = null;
            DateTime?dateTo = null;
            string   transferno = ""; Int32 rcptno = 0;
            int      yearIdno = Convert.ToInt32(ddlDateRange.SelectedValue);

            if (txtDateFrom.Text != "")
            {
                dateFrom = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateFrom.Text));
            }
            else
            {
                dateFrom = null;
            }
            if (txtDateTo.Text != "")
            {
                dateTo = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text));
            }
            else
            {
                dateTo = null;
            }
            transferno = Convert.ToString(txtMtrlTransfno.Text);
            rcptno     = (Convert.ToString(txtRcptNo.Text) != "" ? Convert.ToInt32(txtRcptNo.Text) : 0);
            Int32             Fromcity             = Convert.ToInt32(ddlTocity.SelectedValue);
            ChallanDelverdDAL objChallanDelverdDAL = new ChallanDelverdDAL();
            var lst = objChallanDelverdDAL.Search(dateFrom, dateTo, rcptno, transferno, Fromcity, yearIdno);

            objChallanDelverdDAL = null;
            if (lst != null && lst.Count > 0)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("SrNo", typeof(string));
                dt.Columns.Add("Date", typeof(string));
                dt.Columns.Add("DelvNo", typeof(string));
                dt.Columns.Add("ToCity", typeof(string));
                dt.Columns.Add("ChallanNo", typeof(string));
                dt.Columns.Add("ChlnDate", typeof(string));


                double TNet = 0; double TAmnt = 0;
                for (int i = 0; i < lst.Count; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr["SrNo"]      = Convert.ToString(i + 1);
                    dr["Date"]      = Convert.ToDateTime(DataBinder.Eval(lst[i], "ChlnDelv_Date")).ToString("dd-MM-yyyy");
                    dr["DelvNo"]    = Convert.ToString(DataBinder.Eval(lst[i], "ChlnDelv_No"));
                    dr["ToCity"]    = Convert.ToString(DataBinder.Eval(lst[i], "City_Name"));
                    dr["ChallanNo"] = Convert.ToString(DataBinder.Eval(lst[i], "Chln_No"));
                    dr["ChlnDate"]  = Convert.ToDateTime(DataBinder.Eval(lst[i], "Chln_Date")).ToString("dd-MM-yyyy");

                    dt.Rows.Add(dr);
                }
                if (dt != null && dt.Rows.Count > 0)
                {
                    ViewState["Dt"] = dt;
                }


                //
                grdUser.DataSource = lst;
                grdUser.DataBind();
                imgBtnExcel.Visible = true;
            }
            else
            {
                grdUser.DataSource = null;
                grdUser.DataBind();
                imgBtnExcel.Visible = false;
            }
            lbltotalstaff.Text = "T. Record (s): " + lst.Count;
        }