//Add CityArea
        public int AddCityArea(Master_CityArea ca)
        {
            int  i;
            bool isnotValid = false;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                string     q   = "select count(*) from Master_CityArea where AreaCode=@AreaCode";
                SqlCommand com = new SqlCommand(q, con);
                com.Parameters.AddWithValue("@AreaCode", ca.AreaCode);
                isnotValid = (int)com.ExecuteScalar() > 0;
                if (isnotValid)
                {
                    i = 0;
                    return(i);
                }
            }


            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                string q = "insert into Master_CityArea(AreaCode,AreaName,CityCode) values(@AreaCode,@AreaName,@CityCode)";

                SqlCommand com = new SqlCommand(q, con);
                com.Parameters.AddWithValue("@AreaCode", ca.AreaCode);
                com.Parameters.AddWithValue("@AreaName", ca.AreaName);
                com.Parameters.AddWithValue("@CityCode", ca.CityCode);
                i = com.ExecuteNonQuery();
            }

            return(i);
        }
        //update cityarea
        public int Updatecityarea(Master_CityArea a)
        {
            int i;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                string     q   = "update Master_CityArea set  AreaName=@AreaName where AreaCode=@AreaCode";
                SqlCommand com = new SqlCommand(q, con);
                com.Parameters.AddWithValue("@AreaCode", a.AreaCode);
                com.Parameters.AddWithValue("@AreaName", a.AreaName);

                i = com.ExecuteNonQuery();
            }
            return(i);
        }
Beispiel #3
0
 public JsonResult Updatecityarea(Master_CityArea c)
 {
     return(Json(db.Updatecityarea(c), JsonRequestBehavior.AllowGet));
 }
Beispiel #4
0
 public JsonResult Addcityarea(Master_CityArea ca)
 {
     return(Json(db.AddCityArea(ca), JsonRequestBehavior.AllowGet));
 }