コード例 #1
0
        protected void lnkbtnSave_OnClick(object sender, EventArgs e)
        {
            Int32       empIdno     = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString());
            string      strMsg      = string.Empty;
            TollMastDAL objTolMast  = new TollMastDAL();
            Int64       intCityIdno = 0;

            if (drpCity.SelectedValue != ddlToCity.SelectedValue)
            {
                if (string.IsNullOrEmpty(hidcityidno.Value) == true)
                {
                    intCityIdno = objTolMast.InsertTollMaster(txtTolTaxName.Text.Trim(), Convert.ToInt64(drpCity.SelectedValue), Convert.ToInt64(ddlToCity.SelectedValue), float.Parse(string.IsNullOrEmpty(txtAmount.Text) ? "0" : txtAmount.Text), Convert.ToBoolean(chkStatus.Checked), Convert.ToInt32(ddllorytype.SelectedValue), empIdno);
                }
                else
                {
                    intCityIdno = objTolMast.UpdateTollMaster(txtTolTaxName.Text.Trim(), Convert.ToInt32(hidcityidno.Value), Convert.ToInt64(drpCity.SelectedValue), Convert.ToInt64(ddlToCity.SelectedValue), float.Parse(txtAmount.Text), Convert.ToBoolean(chkStatus.Checked), Convert.ToInt32(ddllorytype.SelectedValue), empIdno);
                }
                objTolMast = null;

                if (intCityIdno > 0)
                {
                    if (string.IsNullOrEmpty(hidcityidno.Value) == false)
                    {
                        ShowMessage("Record updated successfully.");
                    }
                    else
                    {
                        ShowMessage("Record saved successfully.");
                    }
                    ClearControls();
                    lnkbtnNew.Visible = false;
                }
                else if (intCityIdno < 0)
                {
                    ShowMessageErr("Record already exists.");
                }
                else
                {
                    if (string.IsNullOrEmpty(hidcityidno.Value) == false)
                    {
                        ShowMessageErr("Record not updated.");
                    }
                    else
                    {
                        ShowMessageErr("Record not saved.");
                    }
                }
                drpCity.Focus();
            }
            else
            {
                ShowMessageErr("From City And To City Can't Same");
            }
        }
コード例 #2
0
        private void BindLorryType()
        {
            TollMastDAL Obj  = new TollMastDAL();
            var         EMPS = Obj.SelectLorryType();

            ddllorytype.DataSource     = EMPS;
            ddllorytype.DataTextField  = "Lorry_Type";
            ddllorytype.DataValueField = "Id";
            ddllorytype.DataBind();
            ddllorytype.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0"));
            Obj = null;
        }
コード例 #3
0
        private void BindCity()
        {
            TollMastDAL objTollMastDAL = new TollMastDAL();
            var         lst            = objTollMastDAL.BindCityAll();

            drpCity.DataSource     = lst;
            drpCity.DataTextField  = "City_Name";
            drpCity.DataValueField = "City_Idno";
            drpCity.DataBind();
            drpCity.Items.Insert(0, new ListItem("< Choose City >", "0"));


            ddlToCity.DataSource     = lst;
            ddlToCity.DataTextField  = "City_Name";
            ddlToCity.DataValueField = "City_Idno";
            ddlToCity.DataBind();
            ddlToCity.Items.Insert(0, new ListItem("< Choose City >", "0"));
        }
コード例 #4
0
        private void Populate(int Tolltaxid)
        {
            TollMastDAL objtollmast = new TollMastDAL();
            var         objTollMast = objtollmast.SelectById(Tolltaxid);

            objtollmast = null;
            if (objTollMast != null)
            {
                drpCity.SelectedValue   = Convert.ToString(objTollMast.city);
                ddlToCity.SelectedValue = Convert.ToString(objTollMast.Tocity);
                txtTolTaxName.Text      = Convert.ToString(objTollMast.Tolltax_name);
                txtAmount.Text          = (txtAmount.Text);
                //txtAmount.Text = Convert.ToString(txtAmount.Text);
                txtAmount.Text            = Convert.ToString(objTollMast.Amount);
                chkStatus.Checked         = Convert.ToBoolean(objTollMast.Status);
                hidcityidno.Value         = Convert.ToString(objTollMast.Toll_id);
                ddllorytype.SelectedValue = string.IsNullOrEmpty(Convert.ToString(objTollMast.LorryType_Idno)) ? "0" : Convert.ToString(objTollMast.LorryType_Idno);
                drpCity.Focus();
            }
        }
コード例 #5
0
        protected void grdMain_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ImageButton imgBtnStatus = (ImageButton)e.Row.FindControl("imgBtnStatus");
                bool        status       = Convert.ToBoolean(DataBinder.Eval(e.Row.DataItem, "Status"));


                LinkButton lnkbtnEdit   = (LinkButton)e.Row.FindControl("lnkbtnEdit");
                LinkButton lnkbtnDelete = (LinkButton)e.Row.FindControl("lnkbtnDelete");
                Int32      Tollid       = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "TollTaxid"));


                drLblNet += Convert.ToDouble(DataBinder.Eval(e.Row.DataItem, "Ammount"));

                base.CheckUserRights(intFormId);
                if (base.Edit == false)
                {
                    imgBtnStatus.Visible       = true;
                    lnkbtnEdit.Visible         = false;
                    grdMain.Columns[3].Visible = false;
                }
                if (base.Delete == false)
                {
                    if (Tollid > 0)
                    {
                        TollMastDAL obj       = new TollMastDAL();
                        var         ItemExist = obj.CheckItemExistInOtherMaster(Convert.ToInt32(Tollid));
                        if (ItemExist != null && ItemExist.Count > 0)
                        {
                            lnkbtnDelete.Visible = false;
                        }
                        else
                        {
                            lnkbtnDelete.Visible = true;
                        }
                    }
                }
                if ((base.Edit == false) && (base.Delete == false))
                {
                    grdMain.Columns[4].Visible = false;
                }
                if (Tollid > 0)
                {
                    TollMastDAL obj       = new TollMastDAL();
                    var         ItemExist = obj.CheckItemExistInOtherMaster(Convert.ToInt32(Tollid));
                    if (ItemExist != null && ItemExist.Count > 0)
                    {
                        lnkbtnDelete.Visible = false;
                    }
                    else
                    {
                        lnkbtnDelete.Visible = true;
                    }
                }
                if (status == false)
                {
                    imgBtnStatus.ImageUrl = "~/Images/inactive.png";
                }
                else
                {
                    imgBtnStatus.ImageUrl = "~/Images/active.png";
                }
            }

            if (e.Row.RowType == DataControlRowType.Footer)
            {
                Label lblTotalNet = (Label)e.Row.FindControl("lblTotalNet");
                lblTotalNet.Text = drLblNet.ToString("N2");
            }
        }
コード例 #6
0
        protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Int32  empIdno = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString());
            string strMsg  = string.Empty;

            if (e.CommandName == "cmdedit")
            {
                Response.Redirect("TolTaxMaster.aspx?TollTaxId=" + e.CommandArgument, true);
            }
            if (e.CommandName == "cmddelete")
            {
                TollMastDAL objTollMast = new TollMastDAL();
                Int32       intValue    = objTollMast.Delete(Convert.ToInt32(e.CommandArgument));
                objTollMast = null;
                if (intValue > 0)
                {
                    this.BindGrid();
                    strMsg = "Record deleted successfully.";
                    txttollname.Focus();
                }
                else
                {
                    if (intValue == -1)
                    {
                        strMsg = "Record can not be deleted. It is in use.";
                    }
                    else
                    {
                        strMsg = "Record not deleted.";
                    }
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
            }
            else if (e.CommandName == "cmdstatus")
            {
                int      intTollIdno = 0;
                bool     bStatus     = false;
                string[] strStatus   = Convert.ToString(e.CommandArgument).Split(new char[] { '_' });
                if (strStatus.Length > 1)
                {
                    intTollIdno = Convert.ToInt32(strStatus[0]);
                    if (Convert.ToBoolean(strStatus[1]) == true)
                    {
                        bStatus = false;
                    }
                    else
                    {
                        bStatus = true;
                    }
                    TollMastDAL objDrivMast = new TollMastDAL();
                    int         value       = objDrivMast.UpdateStatus(intTollIdno, bStatus, empIdno);
                    objDrivMast = null;
                    if (value > 0)
                    {
                        this.BindGrid();
                        strMsg = "Status updated successfully.";
                        txttollname.Focus();
                    }
                    else
                    {
                        strMsg = "Status not updated.";
                    }
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
                }
            }
            txttollname.Focus();
        }
コード例 #7
0
        private void BindGrid()
        {
            var city = 0;

            if (drpCity.SelectedValue != "")
            {
                city = Convert.ToInt32(drpCity.SelectedValue);
            }
            TollMastDAL objDrivMast = new TollMastDAL();
            var         lstGridData = objDrivMast.SelectForSearch(Convert.ToInt32(city), Convert.ToInt32(ddlToCity.SelectedValue), Convert.ToString(txttollname.Text.Trim()), Convert.ToInt32(ddllorytype.SelectedValue));

            objDrivMast = null;
            if (lstGridData != null && lstGridData.Count > 0)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("SrNo", typeof(string));
                dt.Columns.Add("FromCity", typeof(string));
                dt.Columns.Add("ToCity", typeof(string));
                dt.Columns.Add("TollName", typeof(string));
                dt.Columns.Add("LorryType", typeof(string));
                dt.Columns.Add("Amount", typeof(string));
                dt.Columns.Add("Status", typeof(string));

                double TNet = 0;
                for (int i = 0; i < lstGridData.Count; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr["SrNo"]      = Convert.ToString(i + 1);
                    dr["FromCity"]  = Convert.ToString(DataBinder.Eval(lstGridData[i], "CityName"));
                    dr["ToCity"]    = Convert.ToString(DataBinder.Eval(lstGridData[i], "ToCityName"));
                    dr["TollName"]  = Convert.ToString(DataBinder.Eval(lstGridData[i], "TollTaxName"));
                    dr["LorryType"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "Lorry_Type"));
                    dr["Amount"]    = Convert.ToDouble(DataBinder.Eval(lstGridData[i], "Ammount")).ToString("N2");
                    dr["Status"]    = Convert.ToBoolean(DataBinder.Eval(lstGridData[i], "Status")) == true?"Active":"InActive";
                    dt.Rows.Add(dr);

                    TNet += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "Ammount"));
                    if (i == lstGridData.Count - 1)
                    {
                        DataRow drr = dt.NewRow();
                        drr["LorryType"] = "Total";
                        drr["Amount"]    = (TNet).ToString("N2");
                        dt.Rows.Add(drr);
                    }
                }
                if (dt != null && dt.Rows.Count > 0)
                {
                    ViewState["Dt"] = dt;
                }


                //
                grdMain.DataSource = lstGridData;
                grdMain.DataBind();

                Double TotalNetAmount = 0;

                for (int i = 0; i < lstGridData.Count; i++)
                {
                    TotalNetAmount += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "Ammount"));
                }
                lblNetTotalAmount.Text = TotalNetAmount.ToString("N2");

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