public bool AddMCountry(MCountry mcountry) { SqlCommand cmd; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "AddMCountry"; cmd.Parameters.AddWithValue("@CountryNo", mcountry.CountryNo); cmd.Parameters.AddWithValue("@CountryName", mcountry.CountryName); cmd.Parameters.AddWithValue("@CountryShortCode", mcountry.CountryShortCode); cmd.Parameters.AddWithValue("@CountryLangName", mcountry.CountryLangName); cmd.Parameters.AddWithValue("@IsActive", mcountry.IsActive); cmd.Parameters.AddWithValue("@UserID", mcountry.UserID); cmd.Parameters.AddWithValue("@UserDate", mcountry.UserDate); //cmd.Parameters.AddWithValue("@ModifiedBy", mcountry.ModifiedBy); if (ObjTrans.ExecuteNonQuery(cmd, CommonFunctions.ConStr) == true) { return(true); } else { mcountry.msg = ObjTrans.ErrorMessage; return(false); } }
public MCountry ModifyMCountryByID(long ID) { SqlConnection Con = new SqlConnection(CommonFunctions.ConStr); string sql; SqlCommand cmd; sql = "Select * from MCountry where CountryNo =" + 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) { MCountry MM = new MCountry(); while (dr.Read()) { MM.CountryNo = Convert.ToInt32(dr["CountryNo"]); if (!Convert.IsDBNull(dr["CountryName"])) { MM.CountryName = Convert.ToString(dr["CountryName"]); } if (!Convert.IsDBNull(dr["CountryShortCode"])) { MM.CountryShortCode = Convert.ToString(dr["CountryShortCode"]); } if (!Convert.IsDBNull(dr["CountryLangName"])) { MM.CountryLangName = Convert.ToString(dr["CountryLangName"]); } 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"]); } } dr.Close(); return(MM); } else { dr.Close(); } return(new MCountry()); }
public bool DeleteMCountry(MCountry mcountry) { SqlCommand cmd; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "DeleteMCountry"; cmd.Parameters.AddWithValue("@CountryNo", mcountry.CountryNo); if (ObjTrans.ExecuteNonQuery(cmd, CommonFunctions.ConStr) == true) { return(true); } else { mcountry.msg = ObjTrans.ErrorMessage; return(false); } }