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