예제 #1
0
        private void fillControls(SqlInt32 CityID)
        {
            CitiesENT entCity = new CitiesENT();
            CitiesBAL balCity = new CitiesBAL();

            entCity = balCity.SelectByPK(CityID);
            if (entCity != null)
            {
                if (!entCity.CityName.IsNull)
                {
                    txtCityName.Text = entCity.CityName.Value.ToString();
                }
                if (!entCity.Pincode.IsNull)
                {
                    txtPincode.Text = entCity.Pincode.Value.ToString();
                }
                if (!entCity.STDCode.IsNull)
                {
                    txtSTDCode.Text = entCity.STDCode.Value.ToString();
                }
                if (!entCity.StateID.IsNull)
                {
                    ddlState.SelectedValue = entCity.StateID.Value.ToString();
                }
            }
            else
            {
                lblError.Text = balCity.Message;
            }
        }
예제 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            #region Server Side Validation
            lblError.Text = "";
            if (txtCityName.Text.Trim().ToUpper() == "")
            {
                lblError.Text += "Enter City Name <br/>";
            }

            if (ddlState.SelectedValue == "-1")
            {
                lblError.Text += "Please Select State <br/>";
            }

            if (lblError.Text != "")
            {
                return;
            }
            #endregion Server Side Validation

            #region Collecting Data
            CitiesENT entCity = new CitiesENT();
            if (ddlState.SelectedValue != "-1" && txtCityName.Text.Trim().ToUpper() != "")
            {
                entCity.CityName = txtCityName.Text.Trim().ToUpper();
                entCity.StateID  = Convert.ToInt32(ddlState.SelectedValue);
                entCity.Pincode  = txtPincode.Text.Trim();
                entCity.STDCode  = txtSTDCode.Text.Trim();
            }
            CitiesBAL balCity = new CitiesBAL();
            #endregion Collecting Data
            if (Request.QueryString["CityID"] == null)
            {
                #region insertingData
                if (balCity.Insert(entCity))
                {
                    Response.Redirect("~/AdminPanel/City/CityList.aspx");
                }
                else
                {
                    lblError.Text = balCity.Message;
                }
                #endregion insertingData
            }
            else
            {
                #region updatingData
                entCity.CityID = Convert.ToInt32(Request.QueryString["CityID"]);
                if (balCity.Update(entCity))
                {
                    Response.Redirect("~/AdminPanel/City/CityList.aspx");
                }
                else
                {
                    lblError.Text = balCity.Message;
                }
                #endregion updatingData
            }
        }
예제 #3
0
        private void FillGridViewCity()
        {
            CitiesBAL balCity = new CitiesBAL();
            DataTable dtCity  = new DataTable();

            dtCity = balCity.SelectAll();
            if (dtCity != null && dtCity.Rows.Count > 0)
            {
            }
        }
예제 #4
0
        public static void FillDropDownListCity(DropDownList ddl)
        {
            CitiesBAL balCity = new CitiesBAL();

            ddl.DataSource     = balCity.SelectForDropdownList();
            ddl.DataValueField = "CityID";
            ddl.DataTextField  = "CityName";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select Item", "-1"));
        }
예제 #5
0
        private void FillGridViewCity()
        {
            CitiesBAL balCity = new CitiesBAL();
            DataTable dtCity  = new DataTable();

            dtCity = balCity.SelectAll();
            if (dtCity != null && dtCity.Rows.Count > 0)
            {
                gvCityList.DataSource = dtCity;
                gvCityList.DataBind();
            }
        }
예제 #6
0
 protected void gvCityList_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandArgument != null)
     {
         CitiesBAL balCity = new CitiesBAL();
         if (balCity.Delete(Convert.ToInt32(e.CommandArgument.ToString().Trim())))
         {
             Response.Redirect("~/Adminpanel/City/CityList.aspx");
             lblError.Text = "";
         }
         else
         {
             lblError.Text = balCity.Message;
         }
     }
 }