コード例 #1
0
        /// <summary>
        /// 新增验证
        /// </summary>
        /// <param name="userinfo"></param>
        /// <returns></returns>
        public ActionResult CheckAdd(Water_solid model)
        {
            string otype  = model != null && model.ID == 0 ? "add" : "update";
            var    result = 0;
            Expression <Func <Water_solid, bool> > wherelambad = u => 1 == 1;//查询条件;

            if (otype == "add")
            {
                model.CreateTime = model.UpdateTime = DateTime.Now;
                model.CreateUser = model.UpdateUser = 1;
                result           = Bll.Add(model);
            }
            else
            {
                model.UpdateTime = DateTime.Now;
                result           = Bll.Update(model);
            }
            if (result != 0)
            {
                string msg = CommonMsg.SuccessAlert(200, "操作成功 ! ", "Water_solid", callbackType: "closeCurrent");
                return(Content(msg));
            }
            else
            {
                return(Content(CommonMsg.ErrorAlert(300, "操作失败")));
            }
        }
コード例 #2
0
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public ActionResult RecoverUserInfoByIds(string ids)
        {
            #region ef使用sql更新示例
            // 执行Update语句
            //            string strUpdateSQL = @"UPDATE test SET password=@pwd1 WHERE id=@id1;
            //UPDATE test SET password=@pwd2 WHERE id=@id2;";
            //            SqlParameter[] para =  {
            //                   new  SqlParameter("@pwd1","ceshi12we"),
            //                   new  SqlParameter("@id1",1),
            //                   new  SqlParameter("@pwd2","ceshi127890"),
            //                   new  SqlParameter("@id2",2),
            //                };

            //            int result = entity.Database.ExecuteSqlCommand(strUpdateSQL, para);
            //            if (result > 0)
            //            {
            //                Console.WriteLine("更新成功");
            //            }
            #endregion


            int result = db.Database.ExecuteSqlCommand(@"update sys_userinfo set S_state=0 where S_state=1 and   id in(" + ids.Trim().Trim(',') + ")");
            if (result != 0)
            {
                return(Content(CommonMsg.SuccessAlert(200, "操作成功", "sys_userinfo")));
            }
            else
            {
                return(Content(CommonMsg.ErrorAlert(300, "操作失败")));
            }
        }
コード例 #3
0
        /// <summary>
        /// 新增验证
        /// </summary>
        /// <param name="userinfo"></param>
        /// <returns></returns>
        public ActionResult Checkpolyester_chip(polyester_chip model)
        {
            #region sqlserver时间格式
            //时间格式转换错误,https://blog.csdn.net/mini_joyce/article/details/58082853
            //SQL Server中DateTime与DateTime2的区别
            //DateTime字段类型对应的时间格式是 yyyy-MM-dd HH:mm:ss.fff ,3个f,精确到1毫秒(ms),示例 2014-12-03 17:06:15.433 。
            //DateTime2字段类型对应的时间格式是 yyyy-MM-dd HH:mm:ss.fffffff ,7个f,精确到0.1微秒(μs),示例 2014-12-03 17:23:19.2880929 。
            //如果用SQL的日期函数进行赋值,DateTime字段类型要用 GETDATE() ,DateTime2字段类型要用 SYSDATETIME() 。
            #endregion


            LogUtil.WiteLog.WriteLogs("ID:" + model.ID, "testlog");
            string otype  = model != null && model.ID == 0 ? "add" : "update";
            var    result = 0;
            Expression <Func <polyester_chip, bool> > wherelambad = u => 1 == 1;//查询条件;
            if (otype == "add")
            {
                model.CreateTime = model.UpdateTime = DateTime.Now;
                model.CreateUser = model.UpdateUser = 10000;
                result           = Bll.Add(model);
            }
            else
            {
                var modelNew = db.polyester_chip.Where(a => a.ID == model.ID).FirstOrDefault();   //根据ID查询数据,再次重新赋值,这样DateTime类型就不会出现错误??
                modelNew.UpdateTime      = DateTime.Now;
                modelNew.PC_ChekTime     = model.PC_ChekTime;
                modelNew.PC_InGoodsNum   = model.PC_InGoodsNum;
                modelNew.PC_WetSectionH  = model.PC_WetSectionH;
                modelNew.PC_H1           = model.PC_H1;
                modelNew.PC_H2           = model.PC_H2;
                modelNew.PC_WaterCompent = model.PC_WaterCompent;
                modelNew.PC_FCheckWater  = model.PC_FCheckWater;
                modelNew.PC_FCheckSS     = model.PC_FCheckSS;
                modelNew.PC_HundredW1    = model.PC_HundredW1;
                modelNew.PC_HundredW2    = model.PC_HundredW2;
                modelNew.PC_CheckUser    = model.PC_CheckUser;
                modelNew.PC_FName        = model.PC_FName;
                modelNew.PC_PCode        = model.PC_PCode;
                modelNew.PC_HeapUPD      = model.PC_HeapUPD;
                modelNew.PC_MeltingP     = model.PC_MeltingP;
                modelNew.PC_Remark       = model.PC_Remark;
                modelNew.PC_PassMsg      = model.PC_PassMsg;
                result = Bll.Update(modelNew);
            }
            if (result != 0)
            {
                string msg = CommonMsg.SuccessAlert(200, "操作成功 ! ", "polyester_chip", callbackType: "closeCurrent");
                return(Content(msg));
            }
            else
            {
                return(Content(CommonMsg.ErrorAlert(300, "操作失败")));
            }
        }
コード例 #4
0
        /// <summary>
        /// 批量恢复
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public ActionResult RecoverRoleInfoByIds(string ids)
        {
            var result = db.Database.ExecuteSqlCommand(@"update sys_role set s_state=0 where s_state=1 and   id in(" + ids.Trim().Trim(',') + ")");

            if (result != 0)
            {
                return(Content(CommonMsg.SuccessAlert(200, "操作成功", "sys_role")));
            }
            else
            {
                return(Content(CommonMsg.ErrorAlert(300, "操作失败")));
            }
        }
コード例 #5
0
        /// <summary>
        /// 批量删除/2021/2/1
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public ActionResult DeleteUserInfoByIds(string ids)
        {
            //注意:执行DDL语句(create、alter、drop等)返回值是-1,DML(insert、update、delete)返回的是受影响的行数
            int result = db.Database.ExecuteSqlCommand(@"update sys_userinfo set S_state=1,updatetime='" + DateTime.Now + "' where S_state=0 and   id in(" + ids.Trim().Trim(',') + ")");

            if (result != 0)
            {
                return(Content(CommonMsg.SuccessAlert(200, "操作成功", "sys_userinfo")));
            }
            else
            {
                return(Content(CommonMsg.ErrorAlert(300, "操作失败")));
            }
        }
コード例 #6
0
        /// <summary>
        /// 新增验证
        /// </summary>
        /// <param name="userinfo"></param>
        /// <returns></returns>
        public ActionResult CheckUserInfo(sys_userinfo userinfo)
        {
            string otype  = userinfo != null && userinfo.ID == 0 ? "add" : "update";
            var    result = 0;
            Expression <Func <sys_userinfo, bool> > wherelambad = u => 1 == 1;//查询条件;

            if (otype == "add")
            {
                if (!string.IsNullOrWhiteSpace(userinfo.S_username))
                {
                    wherelambad = wherelambad = u => u.S_username.Equals(userinfo.S_username);
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(userinfo.S_username) && userinfo.ID != 0)
                {
                    wherelambad = wherelambad = u => u.S_username.Equals(userinfo.S_username) && u.ID != userinfo.ID;
                }
            }
            var data = Bll.GetEntitysByStrwhere(wherelambad).ToList().Count();

            if (data != 0)
            {
                return(Content(CommonMsg.ErrorAlert(300, "用户名[" + userinfo.S_username + "]已经存在")));
            }
            if (otype == "add")
            {
                userinfo.S_checkUID = 1;
                userinfo.S_roleId   = 2;
                userinfo.CreateTime = userinfo.UpdateTime = DateTime.Now;
                userinfo.CreateUser = userinfo.UpdateUser = 10000;
                result = Bll.Addsys_userinfo(userinfo);
            }
            else
            {
                userinfo.UpdateTime = DateTime.Now;
                result = Bll.UpdateSys_userinfo(userinfo);
            }
            if (result != 0)
            {
                string msg = CommonMsg.SuccessAlert(200, "操作成功 ! ", "sys_userinfo", callbackType: "closeCurrent");
                return(Content(msg));
            }
            else
            {
                return(Content(CommonMsg.ErrorAlert(300, "操作失败")));
            }
        }
コード例 #7
0
        /// <summary>
        /// 单个启用数据
        /// </summary>
        /// <param name="OID"></param>
        public ActionResult RecoverSysRole(int?OID)
        {
            var id     = OID.HasValue ? OID : 0;
            var result = 0;
            var data   = Bll.GetEntitysByStrwhere(u => u.ID == OID).FirstOrDefault();

            if (data != null)
            {
                data.S_state    = 0;
                data.ID         = Convert.ToInt32(id);
                data.UpdateTime = DateTime.Now;
                result          = Bll.UpdateSys_role(data);
            }
            if (result != 0)
            {
                return(Content(CommonMsg.SuccessAlert(200, "启用成功", "sys_role")));//Content表示的是返回文本数据
            }
            else
            {
                return(Content(CommonMsg.ErrorAlert(300, "操作失败")));
            }
        }
コード例 #8
0
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="OID"></param>
        /// <returns></returns>
        public ActionResult DeleteUserInfo(int?OID, string otype)
        {
            var id     = OID.HasValue ? OID : 0;
            var result = 0;
            var data   = Bll.GetEntitysByStrwhere(u => u.ID == OID).FirstOrDefault();

            if (data != null)
            {
                data.S_state    = (otype == "delete" ? 1 : 0);
                data.ID         = Convert.ToInt32(id);
                data.UpdateTime = DateTime.Now;
                result          = Bll.UpdateSys_userinfo(data);
            }
            if (result != 0)
            {
                return(Content(CommonMsg.SuccessAlert(200, "操作成功", "sys_userinfo")));
            }
            else
            {
                return(Content(CommonMsg.ErrorAlert(300, "操作失败")));
            }
        }