Exemple #1
0
        //编辑,新增
        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));
            }
        }
Exemple #2
0
        //返回list数据
        public JsonResult list(ListData obj)
        {
            var list = new Dal.Basedata.t_bmDal(obj).ToList();

            return(Json(new
            {
                rows = list
            }));
        }
Exemple #3
0
        //保存
        public JsonResult Save(t_bm 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_bmDal(dic, "code").ToList();
                if (list.Count > 0)
                {
                    return(Json(new { success = "error", message = ",该编号已经存在" }));
                }
            }

            try
            {
                new Dal.Basedata.t_bmDal().Save(obj);
                return(Json(new { success = "ok" }));
            }
            catch (Exception e)
            {
                return(Json(new { success = "error", message = e.Message }));
            }
        }