/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.T_DIC_Supplier model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_DIC_Supplier("); strSql.Append("Coding,NameEntity,AddressEntity,Contact,Phone)"); strSql.Append(" values ("); strSql.Append("@Coding,@NameEntity,@AddressEntity,@Contact,@Phone)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Coding", SqlDbType.NChar, 10), new SqlParameter("@NameEntity", SqlDbType.NVarChar, 50), new SqlParameter("@AddressEntity", SqlDbType.NVarChar, 50), new SqlParameter("@Contact", SqlDbType.NVarChar, 30), new SqlParameter("@Phone", SqlDbType.NVarChar, 20) }; parameters[0].Value = model.Coding; parameters[1].Value = model.NameEntity; parameters[2].Value = model.AddressEntity; parameters[3].Value = model.Contact; parameters[4].Value = model.Phone; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.T_DIC_Supplier DataRowToModel(DataRow row) { Model.T_DIC_Supplier model = new Model.T_DIC_Supplier(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["Coding"] != null) { model.Coding = row["Coding"].ToString(); } if (row["NameEntity"] != null) { model.NameEntity = row["NameEntity"].ToString(); } if (row["AddressEntity"] != null) { model.AddressEntity = row["AddressEntity"].ToString(); } if (row["Contact"] != null) { model.Contact = row["Contact"].ToString(); } if (row["Phone"] != null) { model.Phone = row["Phone"].ToString(); } } return(model); }
/// <summary> /// EditSupplier /// </summary> /// <param name="uid"></param> /// <returns></returns> public ActionResult EditSupplier(int uid) { BLL.T_DIC_Supplier bll = new BLL.T_DIC_Supplier(); Model.T_DIC_Supplier model = bll.GetModel(uid); ViewBag.lst = model; return(View()); }
public JsonResult AddSupplierSave(Model.T_DIC_Supplier model) { BLL.T_DIC_Supplier bll = new BLL.T_DIC_Supplier(); MODEL.Message message; int i = bll.Add(model); if (i > 0) { message = BookProject.Public.T_CloseSMess("SupplierList", "SupplierList", "添加供应商成功!"); } else { message = BookProject.Public.T_CloseFMess("SupplierList", "SupplierList", "添加供应商失败!"); } return(Json(message)); }
public JsonResult EditSupplierSave(Model.T_DIC_Supplier model) { BLL.T_DIC_Supplier bll = new BLL.T_DIC_Supplier(); bool result = bll.Update(model); MODEL.Message message; if (result) { message = BookProject.Public.T_CloseSMess("SupplierList", "SupplierList", "修改供应商成功!"); } else { message = BookProject.Public.T_CloseFMess("SupplierList", "SupplierList", "修改供应商失败!"); } return(Json(message)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.T_DIC_Supplier model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_DIC_Supplier set "); strSql.Append("Coding=@Coding,"); strSql.Append("NameEntity=@NameEntity,"); strSql.Append("AddressEntity=@AddressEntity,"); strSql.Append("Contact=@Contact,"); strSql.Append("Phone=@Phone"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@Coding", SqlDbType.NChar, 10), new SqlParameter("@NameEntity", SqlDbType.NVarChar, 50), new SqlParameter("@AddressEntity", SqlDbType.NVarChar, 50), new SqlParameter("@Contact", SqlDbType.NVarChar, 30), new SqlParameter("@Phone", SqlDbType.NVarChar, 20), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.Coding; parameters[1].Value = model.NameEntity; parameters[2].Value = model.AddressEntity; parameters[3].Value = model.Contact; parameters[4].Value = model.Phone; parameters[5].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.T_DIC_Supplier GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,Coding,NameEntity,AddressEntity,Contact,Phone from T_DIC_Supplier "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Model.T_DIC_Supplier model = new Model.T_DIC_Supplier(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }