public ActionResult DeleteConfirmed(int id) { tb_Supplier tb_Supplier = db.tb_Supplier.Find(id); db.tb_Supplier.Remove(tb_Supplier); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID_Supplier,Name_Supplier,Store_Supplier,Address_Supplier,Tel_Supplier")] tb_Supplier tb_Supplier) { if (ModelState.IsValid) { db.Entry(tb_Supplier).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tb_Supplier)); }
public ActionResult Create([Bind(Include = "ID_Supplier,Name_Supplier,Store_Supplier,Address_Supplier,Tel_Supplier")] tb_Supplier tb_Supplier) { if (ModelState.IsValid) { db.tb_Supplier.Add(tb_Supplier); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tb_Supplier)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(tb_Supplier model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_Supplier("); strSql.Append("name,address,linkMan,linkNum,remark,createUser,createDate,updateUser,updateDate,temp1,temp2,sendAddress,fax,mobliephone,businessscope)"); strSql.Append(" values ("); strSql.Append("@name,@address,@linkMan,@linkNum,@remark,@createUser,@createDate,@updateUser,@updateDate,@temp1,@temp2,@sendAddress,@fax,@mobliephone,@businessscope)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@name", SqlDbType.NVarChar, 200), new SqlParameter("@address", SqlDbType.NVarChar, -1), new SqlParameter("@linkMan", SqlDbType.NVarChar, 200), new SqlParameter("@linkNum", SqlDbType.VarChar, 100), new SqlParameter("@remark", SqlDbType.NVarChar, -1), new SqlParameter("@createUser", SqlDbType.Int, 4), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@updateUser", SqlDbType.Int, 4), new SqlParameter("@updateDate", SqlDbType.DateTime), new SqlParameter("@temp1", SqlDbType.NVarChar, -1), new SqlParameter("@temp2", SqlDbType.NVarChar, -1), new SqlParameter("@sendAddress", SqlDbType.NVarChar, -1), new SqlParameter("@fax", SqlDbType.NVarChar, -1), new SqlParameter("@mobliephone", SqlDbType.NVarChar, -1), new SqlParameter("@businessscope", SqlDbType.NVarChar, -1) }; parameters[0].Value = model.name; parameters[1].Value = model.address; parameters[2].Value = model.linkMan; parameters[3].Value = model.linkNum; parameters[4].Value = model.remark; parameters[5].Value = model.createUser; parameters[6].Value = model.createDate; parameters[7].Value = model.updateUser; parameters[8].Value = model.updateDate; parameters[9].Value = model.temp1; parameters[10].Value = model.temp2; parameters[11].Value = model.sendAddress; parameters[12].Value = model.fax; parameters[13].Value = model.mobliephone; parameters[14].Value = model.businessscope; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
// GET: tb_Supplier/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tb_Supplier tb_Supplier = db.tb_Supplier.Find(id); if (tb_Supplier == null) { return(HttpNotFound()); } return(View(tb_Supplier)); }
/// <summary> /// 新建数据、更新数据 /// 作者:章建国 /// </summary> /// <param name="model">新输入的数据</param> /// <returns></returns> public string doSupplierCU(tb_Supplier model) { string flag = "0"; try { /**********************************/ model.Jkz.type1 = "供应商管理"; model.Jkz.type2 = "健康证"; //model.Jybg.type1 = "供应商管理"; model.Jybg.type2 = "检疫报告"; //model.Jyz.type1 = "供应商管理"; model.Jyz.type2 = "检疫证"; //model.Clws.type1 = "供应商管理"; model.Clws.type2 = "车辆卫生"; //model.Xdzm.type1 = "供应商管理"; model.Xdzm.type2 = "消毒证明"; List <tb_attachment> listattachment = new List <tb_attachment>(); listattachment.Add(model.Jkz); //listattachment.Add(model.Jybg); //listattachment.Add(model.Jyz); listattachment.Add(model.Clws); //listattachment.Add(model.Xdzm); /*********************************/ model.updateDate = DateTime.Now; model.updateUser = CurrentUserInfo.PersonnelID; int tid = 0; if (model.id > 0) { tid = model.id; if (_supplierbll.Update(model)) { flag = "1"; } } else { model.createDate = DateTime.Now; model.createUser = CurrentUserInfo.PersonnelID; if (_supplierbll.Add(model) > 0) { string where = string.Format(" name = '{0}' and address = '{1}'", model.name, model.address); tid = _supplierbll.GetModelList(where).First().id; flag = "1"; } } doattachment(tid, listattachment); } catch { flag = "0"; } return(flag); }
/// <summary> /// 得到一个对象实体 /// </summary> public tb_Supplier GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from tb_Supplier "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; tb_Supplier model = new tb_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); } }
/// <summary> /// 得到一个对象实体 /// </summary> public tb_Supplier DataRowToModel(DataRow row) { tb_Supplier model = new tb_Supplier(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["name"] != null) { model.name = row["name"].ToString(); } if (row["address"] != null) { model.address = row["address"].ToString(); } if (row["linkMan"] != null) { model.linkMan = row["linkMan"].ToString(); } if (row["linkNum"] != null) { model.linkNum = row["linkNum"].ToString(); } if (row["remark"] != null) { model.remark = row["remark"].ToString(); } if (row["createUser"] != null && row["createUser"].ToString() != "") { model.createUser = int.Parse(row["createUser"].ToString()); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } if (row["updateUser"] != null && row["updateUser"].ToString() != "") { model.updateUser = int.Parse(row["updateUser"].ToString()); } if (row["updateDate"] != null && row["updateDate"].ToString() != "") { model.updateDate = DateTime.Parse(row["updateDate"].ToString()); } if (row["temp1"] != null) { model.temp1 = row["temp1"].ToString(); } if (row["temp2"] != null) { model.temp2 = row["temp2"].ToString(); } if (row["sendAddress"] != null) { model.sendAddress = row["sendAddress"].ToString(); } if (row["fax"] != null) { model.fax = row["fax"].ToString(); } if (row["mobliephone"] != null) { model.mobliephone = row["mobliephone"].ToString(); } if (row["businessscope"] != null) { model.businessscope = row["businessscope"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(tb_Supplier model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_Supplier set "); strSql.Append("name=@name,"); strSql.Append("address=@address,"); strSql.Append("linkMan=@linkMan,"); strSql.Append("linkNum=@linkNum,"); strSql.Append("remark=@remark,"); strSql.Append("createUser=@createUser,"); strSql.Append("createDate=@createDate,"); strSql.Append("updateUser=@updateUser,"); strSql.Append("updateDate=@updateDate,"); strSql.Append("temp1=@temp1,"); strSql.Append("temp2=@temp2,"); strSql.Append("sendAddress=@sendAddress,"); strSql.Append("fax=@fax,"); strSql.Append("mobliephone=@mobliephone,"); strSql.Append("businessscope=@businessscope"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@name", SqlDbType.NVarChar, 200), new SqlParameter("@address", SqlDbType.NVarChar, -1), new SqlParameter("@linkMan", SqlDbType.NVarChar, 200), new SqlParameter("@linkNum", SqlDbType.VarChar, 100), new SqlParameter("@remark", SqlDbType.NVarChar, -1), new SqlParameter("@createUser", SqlDbType.Int, 4), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@updateUser", SqlDbType.Int, 4), new SqlParameter("@updateDate", SqlDbType.DateTime), new SqlParameter("@temp1", SqlDbType.NVarChar, -1), new SqlParameter("@temp2", SqlDbType.NVarChar, -1), new SqlParameter("@sendAddress", SqlDbType.NVarChar, -1), new SqlParameter("@fax", SqlDbType.NVarChar, -1), new SqlParameter("@mobliephone", SqlDbType.NVarChar, -1), new SqlParameter("@businessscope", SqlDbType.NVarChar, -1), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.name; parameters[1].Value = model.address; parameters[2].Value = model.linkMan; parameters[3].Value = model.linkNum; parameters[4].Value = model.remark; parameters[5].Value = model.createUser; parameters[6].Value = model.createDate; parameters[7].Value = model.updateUser; parameters[8].Value = model.updateDate; parameters[9].Value = model.temp1; parameters[10].Value = model.temp2; parameters[11].Value = model.sendAddress; parameters[12].Value = model.fax; parameters[13].Value = model.mobliephone; parameters[14].Value = model.businessscope; parameters[15].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(tb_Supplier model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(tb_Supplier model) { return(dal.Add(model)); }