//编辑,新增 public ActionResult Details(string code, string deptid, string deptname) { t_user model = new t_user(); if (code == null) { string sql = @"select top 1 bh from t_user where bmbh = '" + deptid + "' order by bh desc"; DataTable dt = DataHelper.GetDataTable(sql); string usercode = deptid + "0001"; if (dt.Rows.Count > 0) { int bh = int.Parse(dt.Rows[0][0].ToString()) + 1; usercode = "0" + bh.ToString(); } return(View(new t_user() { list_id = -1, deptcode = deptid, code = usercode })); } else { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("code", code); model = new Dal.Basedata.t_userDal(dic, "code").ToList().First(); //查找部门 Dictionary <string, string> dicdetp = new Dictionary <string, string>(); dicdetp.Add("deptcode", model.deptcode); var deptmodel = new Dal.Basedata.t_bmDal(dicdetp, "deptcode").ToList().First(); if (deptmodel != null) { //model.bmbh = '[' + deptmodel.bmbm + ']' + deptmodel.bmmc; } return(View(model)); } }
/// <summary> /// 保存 /// </summary> /// <param name="obj"></param> /// <returns></returns> public JsonResult Save(t_user obj) { if (obj.list_id == -1) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("code", obj.code); var list = new Dal.Basedata.t_userDal(dic, "code").ToList(); if (list.Count > 0) { return(Json(new { success = "error", message = ",该编号已经存在" })); } } try { obj.cdefine5 = "否";//默认系统接收通知 是 //obj.bmbh = obj.bmbh.Substring(1, obj.bmbh.IndexOf("]") - 1); new Dal.Basedata.t_userDal().Save(obj); return(Json(new { success = "ok" })); } catch (Exception e) { return(Json(new { success = "error", message = e.Message })); } }
public JsonResult list(ListData obj, string typecode) { if (typecode != null) { if (typecode != "00") { obj.sqls += " and (bmbh = '" + typecode + "') "; } } var list = new Dal.Basedata.t_userDal(obj).ToList(); return(Json(new { rows = list.ToArray(), total = new Dal.Basedata.t_userDal().getDataCount(obj) })); }