Beispiel #1
0
    protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
    {
        ddlState.Items[0].Enabled = false;
        int     StateId = int.Parse(ddlState.SelectedItem.Value);
        DataSet ds      = CityBusinessLayer.GetCityByState(StateId);

        BindDDL(ddlCity, ds, "CityName", "CityID");
        ddlCity.Items.Insert(0, "---Select---");
        lblUpdateAddress.Text = "Plz Select City....";
    }
Beispiel #2
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Label l;

        l = (Label)GridView1.Rows[e.RowIndex].FindControl("lblCityId");
        int CityId = 0;

        CityId = int.Parse(l.Text);
        CityBusinessLayer.DeleteCity(CityId);
        ShowCity();
        lblMsg.Text = "City Deleted Successfully...";
    }
 protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         int     StateId = int.Parse(ddlState.SelectedItem.Value);
         DataSet ds      = CityBusinessLayer.GetCityByState(StateId);
         BindDDL(ddlCity, ds, "CityName", "CityID");
         ddlCity.Items.Insert(0, "SELECT CITY");
     }
     catch (Exception)
     {
         lblMsg.Text = "Plz Select State Name";
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Name"] == null)
     {
         Response.Redirect("~/Admin/frmAdminLogin.aspx");
     }
     if (!IsPostBack)
     {
         ddlCity.DataSource     = CityBusinessLayer.GetCityName();
         ddlCity.DataTextField  = "CityName";
         ddlCity.DataValueField = "CityID";
         ddlCity.DataBind();
     }
 }
Beispiel #5
0
    protected void btnAddCity_Click(object sender, EventArgs e)
    {  //variable declaration
        string CityName, CityCode, CityDescription;
        int    StateID;

        //varaible initialization
        CityCode        = "";
        CityDescription = "";
        CityName        = "";
        StateID         = 0;

        //control's value validation
        if (txtCityName.Text.Trim().Length > 0)
        {
            CityName = txtCityName.Text.Trim();
        }

        else
        {
            lblMsg.Text = "Enter City Name";
        }
        if (txtCityDesc.Text.Trim().Length > 0)
        {
            CityDescription = txtCityDesc.Text.Trim();
        }
        else
        {
            lblMsg.Text = "Enter City Description";
        }

        if (txtCityCode.Text.Trim().Length > 0)
        {
            CityCode = txtCityCode.Text.Trim();
        }
        else
        {
            lblMsg.Text = "Enter City Code";
        }

        StateID = int.Parse(ddlState.SelectedItem.Value);
        //Active = Convert.ToByte(lblActive.Text);
        //make call to business layer

        CityBusinessLayer.InsertCity(CityName, CityDescription, CityCode, StateID);
        lblMsg.Text = "City Added Successfully...";
        txtCityName.Focus();
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        int    CityId = int.Parse(Request["CityId"]);
        string CityName, CityDesc, CityCode;

        //Initialization
        CityName = "";
        CityDesc = "";
        CityCode = "";
        int StateId = 0;

        StateId = int.Parse(ddlState.SelectedItem.Value);
        //Assigning Values
        if (txtCityName.Text.Trim().Length > 0)
        {
            CityName = txtCityName.Text.Trim();
        }
        else
        {
            lblMsg.Text = "Enter City Name...";
        }
        if (txtCityDesc.Text.Trim().Length > 0)
        {
            CityDesc = txtCityDesc.Text.Trim();
        }
        else
        {
            lblMsg.Text = "Enter City Description...";
        }
        if (txtCityCode.Text.Trim().Length > 0)
        {
            CityCode = txtCityCode.Text.Trim();
        }
        else
        {
            lblMsg.Text = "Enter City Code...";
        }

        //Calling CityBusinessLayer

        CityBusinessLayer.UpdateCity(CityId, CityName, CityDesc, CityCode, StateId);
        lblMsg.Text = "City Updated Successfully...";
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Name"] == null)
     {
         Response.Redirect("~/Admin/frmAdminLogin.aspx");
     }
     if (!IsPostBack)
     {
         DataSet ds     = new DataSet();
         int     CityId = int.Parse(Request["CityId"]);
         ds = CityBusinessLayer.GetCityByID(CityId);
         txtCityName.Text        = ds.Tables[0].Rows[0][0].ToString();
         txtCityDesc.Text        = ds.Tables[0].Rows[0][1].ToString();
         txtCityCode.Text        = ds.Tables[0].Rows[0][2].ToString();
         ddlState.DataSource     = StateBusinessLayer.GetStateNameById();
         ddlState.DataTextField  = "StateName";
         ddlState.DataValueField = "StateID";
         ddlState.DataBind();
     }
 }
Beispiel #8
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        CheckBox chk;

        foreach (GridViewRow gr in GridView1.Rows)
        {
            Label l;
            l = (Label)gr.FindControl("lblCityId");
            int CityId = 0;
            CityId = int.Parse(l.Text);
            chk    = (CheckBox)gr.FindControl("chkid");
            if (chk.Checked == true)
            {
                CityBusinessLayer.DeleteCity(CityId);
                lblMsg.Text = "City Deleted Successfully...";
            }
            else
            {
                lblMsg.Text = "No City Selected...";
            }
            ShowCity();
        }
    }
Beispiel #9
0
 public void ShowCity()
 {
     GridView1.DataSource = CityBusinessLayer.ShowAllCity();
     GridView1.DataBind();
 }