public static int Add(SamTemplateItemModel model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into SaM_TemplateItem("); builder.Append("ItemID,ItemName,Remark,ItemCode)"); builder.Append(" values ("); builder.Append("@ItemID,@ItemName,@Remark,@ItemCode)"); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@ItemID", SqlDbType.NVarChar, 0x40), new SqlParameter("@ItemName", SqlDbType.NVarChar, 0x20), new SqlParameter("@Remark", SqlDbType.NVarChar, 0x400), new SqlParameter("@ItemCode", SqlDbType.NVarChar, 0x20) }; commandParameters[0].Value = model.ItemID; commandParameters[1].Value = model.ItemName; commandParameters[2].Value = model.Remark; commandParameters[3].Value = model.ItemCode; return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters)); }
public static int Update(SamTemplateItemModel model) { StringBuilder builder = new StringBuilder(); builder.Append("update SaM_TemplateItem set "); builder.Append("ItemName=@ItemName,"); builder.Append("Remark=@Remark,ItemCode=@ItemCode"); builder.Append(" where ItemID=@ItemID "); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@ItemID", SqlDbType.NVarChar, 0x40), new SqlParameter("@ItemName", SqlDbType.NVarChar, 0x20), new SqlParameter("@Remark", SqlDbType.NVarChar, 0x400), new SqlParameter("@ItemCode", SqlDbType.NVarChar, 0x20) }; commandParameters[0].Value = model.ItemID; commandParameters[1].Value = model.ItemName; commandParameters[2].Value = model.Remark; commandParameters[3].Value = model.ItemCode; return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters)); }
public List <SamTemplateItemModel> DataTableToList(DataTable dt) { List <SamTemplateItemModel> list = new List <SamTemplateItemModel>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { SamTemplateItemModel item = new SamTemplateItemModel { ItemID = dt.Rows[i]["ItemID"].ToString(), ItemName = dt.Rows[i]["ItemName"].ToString(), Remark = dt.Rows[i]["Remark"].ToString(), ItemCode = dt.Rows[i]["ItemCode"].ToString() }; list.Add(item); } } return(list); }
public static SamTemplateItemModel GetModel(string ItemID) { StringBuilder builder = new StringBuilder(); builder.Append("select top 1 ItemID,ItemName,Remark,ItemCode from SaM_TemplateItem "); builder.Append(" where ItemID=@ItemID "); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@ItemID", SqlDbType.NVarChar, 50) }; commandParameters[0].Value = ItemID; SamTemplateItemModel model = new SamTemplateItemModel(); DataTable table = SqlHelper.ExecuteQuery(CommandType.Text, builder.ToString(), commandParameters); if (table.Rows.Count > 0) { model.ItemID = table.Rows[0]["ItemID"].ToString(); model.ItemName = table.Rows[0]["ItemName"].ToString(); model.Remark = table.Rows[0]["Remark"].ToString(); model.ItemCode = table.Rows[0]["ItemCode"].ToString(); return(model); } return(null); }
public int Update(SamTemplateItemModel model) { return(SamTemplateItem.Update(model)); }
public int Add(SamTemplateItemModel model) { return(SamTemplateItem.Add(model)); }