public bool DeleteMCity(MCity mcity) { SqlCommand cmd; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "DeleteMCity"; cmd.Parameters.AddWithValue("@CityNo", mcity.CityNo); if (ObjTrans.ExecuteNonQuery(cmd, CommonFunctions.ConStr) == true) { return(true); } else { mcity.msg = ObjTrans.ErrorMessage; return(false); } }
public bool AddMCity(MCity mcity) { SqlCommand cmd; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "AddMCity"; cmd.Parameters.AddWithValue("@CityNo", mcity.CityNo); cmd.Parameters.AddWithValue("@CityName", mcity.CityName); cmd.Parameters.AddWithValue("@CityShortCode", mcity.CityShortCode); cmd.Parameters.AddWithValue("@CityLangName", mcity.CityLangName); //cmd.Parameters.AddWithValue("@CountryNo", mcity.CountryNo); cmd.Parameters.AddWithValue("@StateNo", mcity.StateNo); // cmd.Parameters.AddWithValue("@RegionNo", mcity.RegionNo); cmd.Parameters.AddWithValue("@IsActive", mcity.IsActive); cmd.Parameters.AddWithValue("@UserID", mcity.UserID); cmd.Parameters.AddWithValue("@UserDate", mcity.UserDate); cmd.Parameters.AddWithValue("@CompanyNo", mcity.CompanyNo); //cmd.Parameters.AddWithValue("@ModifiedBy", mcity.ModifiedBy); if (ObjTrans.ExecuteNonQuery(cmd, CommonFunctions.ConStr) == true) { return(true); } else { mcity.msg = ObjTrans.ErrorMessage; return(false); } }
public MCity ModifyMCityByID(long ID) { SqlConnection Con = new SqlConnection(CommonFunctions.ConStr); string sql; SqlCommand cmd; sql = "Select * from MCity where CityNo =" + ID; cmd = new SqlCommand(sql, Con); cmd.Connection = Con; Con.Open(); cmd.CommandType = CommandType.Text; SqlDataReader dr; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (dr.HasRows) { MCity MM = new MCity(); while (dr.Read()) { MM.CityNo = Convert.ToInt32(dr["CityNo"]); if (!Convert.IsDBNull(dr["CityName"])) { MM.CityName = Convert.ToString(dr["CityName"]); } if (!Convert.IsDBNull(dr["CityShortCode"])) { MM.CityShortCode = Convert.ToString(dr["CityShortCode"]); } if (!Convert.IsDBNull(dr["CityLangName"])) { MM.CityLangName = Convert.ToString(dr["CityLangName"]); } //if (!Convert.IsDBNull(dr["CountryNo"])) MM.CountryNo = Convert.ToInt64(dr["CountryNo"]); if (!Convert.IsDBNull(dr["StateNo"])) { MM.StateNo = Convert.ToInt64(dr["StateNo"]); } //if (!Convert.IsDBNull(dr["RegionNo"])) MM.RegionNo = Convert.ToInt64(dr["RegionNo"]); if (!Convert.IsDBNull(dr["IsActive"])) { MM.IsActive = Convert.ToBoolean(dr["IsActive"]); } if (!Convert.IsDBNull(dr["UserID"])) { MM.UserID = Convert.ToInt64(dr["UserID"]); } if (!Convert.IsDBNull(dr["UserDate"])) { MM.UserDate = Convert.ToDateTime(dr["UserDate"]); } if (!Convert.IsDBNull(dr["ModifiedBy"])) { MM.ModifiedBy = Convert.ToString(dr["ModifiedBy"]); } if (!Convert.IsDBNull(dr["CompanyNo"])) { MM.CompanyNo = Convert.ToInt64(dr["CompanyNo"]); } } dr.Close(); return(MM); } else { dr.Close(); } return(new MCity()); }