public int Add(PEIS.Model.DictCountry model) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("insert into DictCountry("); stringBuilder.Append("CountryName,InputCode)"); stringBuilder.Append(" values ("); stringBuilder.Append("@CountryName,@InputCode)"); stringBuilder.Append(";select @@IDENTITY"); SqlParameter[] array = new SqlParameter[] { new SqlParameter("@CountryName", SqlDbType.VarChar, 10), new SqlParameter("@InputCode", SqlDbType.VarChar, 8) }; array[0].Value = model.CountryName; array[1].Value = model.InputCode; object single = DbHelperSQL.GetSingle(stringBuilder.ToString(), array); int result; if (single == null) { result = 0; } else { result = Convert.ToInt32(single); } return(result); }
public PEIS.Model.DictCountry GetModel(int CountryID) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("select top 1 CountryID,CountryName,InputCode from DictCountry "); stringBuilder.Append(" where CountryID=@CountryID"); SqlParameter[] array = new SqlParameter[] { new SqlParameter("@CountryID", SqlDbType.Int, 4) }; array[0].Value = CountryID; PEIS.Model.DictCountry dctCountry = new PEIS.Model.DictCountry(); DataSet dataSet = DbHelperSQL.Query(stringBuilder.ToString(), array); PEIS.Model.DictCountry result; if (dataSet.Tables[0].Rows.Count > 0) { if (dataSet.Tables[0].Rows[0]["CountryID"].ToString() != "") { dctCountry.CountryID = int.Parse(dataSet.Tables[0].Rows[0]["CountryID"].ToString()); } dctCountry.CountryName = dataSet.Tables[0].Rows[0]["CountryName"].ToString(); dctCountry.InputCode = dataSet.Tables[0].Rows[0]["InputCode"].ToString(); result = dctCountry; } else { result = null; } return(result); }
public List <PEIS.Model.DictCountry> DataTableToList(DataTable dt) { List <PEIS.Model.DictCountry> list = new List <PEIS.Model.DictCountry>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { PEIS.Model.DictCountry dctCountry = new PEIS.Model.DictCountry(); if (dt.Rows[i]["CountryID"].ToString() != "") { dctCountry.CountryID = int.Parse(dt.Rows[i]["CountryID"].ToString()); } dctCountry.CountryName = dt.Rows[i]["CountryName"].ToString(); dctCountry.InputCode = dt.Rows[i]["InputCode"].ToString(); list.Add(dctCountry); } } return(list); }
public bool Update(PEIS.Model.DictCountry model) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("update DictCountry set "); stringBuilder.Append("CountryName=@CountryName,"); stringBuilder.Append("InputCode=@InputCode"); stringBuilder.Append(" where CountryID=@CountryID"); SqlParameter[] array = new SqlParameter[] { new SqlParameter("@CountryName", SqlDbType.VarChar, 10), new SqlParameter("@InputCode", SqlDbType.VarChar, 8), new SqlParameter("@CountryID", SqlDbType.Int, 4) }; array[0].Value = model.CountryName; array[1].Value = model.InputCode; array[2].Value = model.CountryID; int num = DbHelperSQL.ExecuteSql(stringBuilder.ToString(), array); return(num > 0); }
public bool Update(PEIS.Model.DictCountry model) { return(this.dal.Update(model)); }
public int Add(PEIS.Model.DictCountry model) { return(this.dal.Add(model)); }