Beispiel #1
0
        /// <summary>
        /// 删除前校验
        /// </summary>
        /// <param name="id"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE Delete_Validate(long id, long user_id, out int n)
        {
            n = 0;
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var data = _dal.FindById(id);

            if (data == null)
            {
                return(ERROR_CODE.ERROR);
            }
            if (data.is_system > 0)
            {
                return(ERROR_CODE.SYSTEM);
            }
            var mar = new crm_account_dal().FindListBySql($"select * from crm_account where classification_id={id} and delete_time=0");

            if (mar.Count > 0)
            {
                n = mar.Count;
                return(ERROR_CODE.ACCOUNT_TYPE_USED);
            }
            data.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            data.delete_user_id = user_id;
            if (!_dal.Update(data))
            {
                return(ERROR_CODE.ERROR);
            }
            return(ERROR_CODE.SUCCESS);
        }
Beispiel #2
0
        public bool EditTicketTmpl(sys_form_tmpl tmpl, sys_form_tmpl_ticket tmplTicket, List <UserDefinedFieldValue> udfValue, List <CheckListDto> checkList, long userId)
        {
            var user = UserInfoBLL.GetUserInfo(userId);
            sys_form_tmpl_ticket_dal sfttDal = new sys_form_tmpl_ticket_dal();
            var oldtmplTicket = sfttDal.FindNoDeleteById(tmplTicket.id);

            if (oldtmplTicket == null || user == null)
            {
                return(false);
            }
            if (!EditFormTmpl(tmpl, userId))
            {
                return(false);
            }
            tmplTicket.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            tmplTicket.update_user_id = userId;
            sfttDal.Update(tmplTicket);
            OperLogBLL.OperLogUpdate <sys_form_tmpl_ticket>(tmplTicket, oldtmplTicket, tmplTicket.id, userId, OPER_LOG_OBJ_CATE.SYS_FORM_TMPL_TICKET, "");

            var udf_ticket_list = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.TICKETS);

            if (udf_ticket_list != null && udf_ticket_list.Count > 0)
            {
                new UserDefinedFieldsBLL().UpdateUdfValue(DicEnum.UDF_CATE.FORM_TICKET, udf_ticket_list, tmplTicket.id, udfValue, user, DicEnum.OPER_LOG_OBJ_CATE.SYS_FORM_TMPL_TICKET_EXT);
            }

            CheckManage(checkList, tmplTicket.id, userId);

            return(true);
        }
Beispiel #3
0
        //删除前的数据校验
        public ERROR_CODE Delete_Valid(long id, long user_id, out string returnvalue)
        {
            returnvalue = string.Empty;
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var data = _dal.FindById(id);

            if (data == null)
            {
                return(ERROR_CODE.ERROR);
            }
            if (data.is_system > 0)
            {
                return(ERROR_CODE.SYSTEM);
            }
            //d_general、ivt_product、crm_installed_product
            //有n个产品种类、n个产品、n个配置项
            int installed_product = new crm_installed_product_dal().ExecuteSQL($"select * from crm_installed_product where cate_id={id} and delete_time=0");
            int product           = new ivt_product_dal().ExecuteSQL($"select * from ivt_product where installed_product_cate_id={id} and delete_time=0");
            int product_cate      = _dal.ExecuteSQL($"select * from d_general where ext1='{id.ToString()}' and delete_time=0");

            if (installed_product > 0 || product > 0 || product_cate > 0)
            {
                returnvalue = @"有" + product_cate + "个产品种类、" + product + "个产品、" + installed_product + "个配置项关联此配置项类型。如果删除,则相关产品种类、产品、配置项上的配置项类型信息将会被清空,并且配置项上将会显示全部相关自定义字段。是否继续";
                return(ERROR_CODE.EXIST);
            }
            return(ERROR_CODE.SUCCESS);
        }
Beispiel #4
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <returns></returns>
        public ERROR_CODE Update(sys_quote_email_tmpl tmpl, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                // 查询不到用户,用户丢失
                return(ERROR_CODE.PARAMS_ERROR);
            }
            tmpl.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            tmpl.update_user_id = user.id;
            if (!dal.Update(tmpl))
            {
                return(ERROR_CODE.ERROR);
            }
            //日志
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE_TEMP,
                oper_object_id      = tmpl.id,// 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = dal.CompareValue(dal.FindNoDeleteById(tmpl.id), tmpl),
                remark              = "修改邮件模板"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志

            return(ERROR_CODE.SUCCESS);
        }
Beispiel #5
0
        /// <summary>
        /// 更改销售订单的状态
        /// </summary>
        /// <returns></returns>
        public bool UpdateSaleOrderStatus(long sid, int status_id, long user_id)
        {
            var sale = _dal.GetSingleSale(sid);
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (sale != null && user != null)
            {
                sale.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                sale.update_user_id = user.id;
                sale.status_id      = status_id;

                new sys_oper_log_dal().Insert(new sys_oper_log()
                {
                    user_cate           = "用户",
                    user_id             = user_id,
                    name                = user.name,
                    phone               = user.mobile == null ? "" : user.mobile,
                    oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                    oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.SALE_ORDER,
                    oper_object_id      = sale.id,// 操作对象id
                    oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                    oper_description    = _dal.CompareValue(_dal.GetSingleSale(sid), sale),
                    remark              = "修改销售订单状态"
                });
                _dal.Update(sale);
                return(true);
            }

            return(false);
        }
Beispiel #6
0
        public ERROR_CODE update(sys_quote_tmpl sqt, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var old = GetQuoteTemplate(sqt.id);

            sqt.update_user_id = user_id;
            sqt.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            if (!_dal.Update(sqt))
            {
                return(ERROR_CODE.ERROR);
            }
            //写个操作日志
            var add_account_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE_TEMP, //数据库缺少对应,报价模板
                oper_object_id      = sqt.id,                            // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = _dal.CompareValue(old, sqt),
                remark              = "更新报价模板"
            };                                              // 创建日志

            new sys_oper_log_dal().Insert(add_account_log); // 插入日志
            return(ERROR_CODE.SUCCESS);
        }
Beispiel #7
0
        public ERROR_CODE Add(sys_quote_tmpl sqt, long user_id, out int id)
        {
            id = sqt.id = (int)(_dal.GetNextIdCom());
            sqt.update_user_id = sqt.create_user_id;
            sqt.create_time    = sqt.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            _dal.Insert(sqt);//把数据保存到数据库表
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var add_account_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE_TEMP,
                oper_object_id      = sqt.id,// 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                oper_description    = _dal.AddValue(sqt),
                remark              = "新增报价模板"
            };                                              // 创建日志

            new sys_oper_log_dal().Insert(add_account_log); // 插入日志

            return(ERROR_CODE.SUCCESS);
        }
Beispiel #8
0
        /// <summary>
        /// 修改产品供应商信息
        /// </summary>
        /// <param name="stock"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE UpdateProductStock(ivt_warehouse_product stock, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            stock.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            stock.update_user_id = user.id;
            var old = Getwarehouse_product(stock.id);

            if (!(new ivt_warehouse_product_dal().Update(stock)))
            {
                return(ERROR_CODE.ERROR);
            }
            //操作日志
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.WAREHOUSE_PRODUCT, //
                oper_object_id      = stock.id,                                 // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = new ivt_warehouse_product_dal().CompareValue(old, stock),
                remark              = "修改产品库存信息"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志
            return(ERROR_CODE.SUCCESS);
        }
Beispiel #9
0
        /// <summary>
        /// 保存权限等级,主要使用更新操作
        /// </summary>
        /// <param name="sqt"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE Save(sys_security_level_limit sqt, long user_id)
        {
            sys_security_level_limit_dal sslld = new sys_security_level_limit_dal();
            var da = sslld.FindSignleBySql <sys_security_level_limit>($"select * from sys_security_level_limit where security_level_id={sqt.security_level_id} and limit_id={sqt.limit_id} ");

            if (da != null)//判断是否已经保存过权限点数据
            {
                if (sqt.limit_type_value_id != da.limit_type_value_id)
                {
                    sslld.Update(sqt);
                    var user = UserInfoBLL.GetUserInfo(user_id);
                    if (user == null)
                    {   // 查询不到用户,用户丢失
                        return(ERROR_CODE.USER_NOT_FIND);
                    }
                    var add_account_log = new sys_oper_log()
                    {
                        user_cate           = "用户",
                        user_id             = user.id,
                        name                = user.name,
                        phone               = user.mobile == null ? "" : user.mobile,
                        oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                        oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.SECURITY_LEVEL,
                        oper_object_id      = sqt.id,// 操作对象id
                        oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                        oper_description    = _dal.AddValue(sqt),
                        remark              = "新增权限点关联模板"
                    };                                              // 创建日志
                    new sys_oper_log_dal().Insert(add_account_log); // 插入日志
                }
            }
            else
            {
                sqt.id = (int)(_dal.GetNextIdCom());
                sslld.Insert(sqt);//把数据保存到数据库表
                var user = UserInfoBLL.GetUserInfo(user_id);
                if (user == null)
                {   // 查询不到用户,用户丢失
                    return(ERROR_CODE.USER_NOT_FIND);
                }
                var add_account_log = new sys_oper_log()
                {
                    user_cate           = "用户",
                    user_id             = user.id,
                    name                = user.name,
                    phone               = user.mobile == null ? "" : user.mobile,
                    oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                    oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.SECURITY_LEVEL,
                    oper_object_id      = sqt.id,// 操作对象id
                    oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                    oper_description    = _dal.AddValue(sqt),
                    remark              = "新增权限点关联模板"
                };                                              // 创建日志
                new sys_oper_log_dal().Insert(add_account_log); // 插入日志
            }



            return(ERROR_CODE.SUCCESS);
        }
Beispiel #10
0
        /// <summary>
        /// 更改报价的排序方式
        /// </summary>
        /// <param name="quote_id"></param>
        /// <param name="group_id"></param>
        /// <param name="user_id"></param>
        public void UpdateGroup(long quote_id, int group_id, long user_id)
        {
            var quote = _dal.GetQuote(quote_id);

            if (quote.group_by_id != group_id) // 未改变分组不用更改
            {
                var user = UserInfoBLL.GetUserInfo(user_id);
                quote.group_by_id    = group_id;
                quote.update_user_id = user_id;
                quote.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                new sys_oper_log_dal().Insert(new sys_oper_log()
                {
                    user_cate           = "用户",
                    user_id             = user_id,
                    name                = user.name,
                    phone               = user.mobile == null ? "" : user.mobile,
                    oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                    oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE,
                    oper_object_id      = quote_id,// 操作对象id
                    oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                    oper_description    = _dal.CompareValue(_dal.GetQuote(quote_id), quote),
                    remark              = "修改报价排序方式"
                });
                _dal.Update(quote);
            }
        }
Beispiel #11
0
        /// <summary>
        /// 报价单绑定报价模板
        /// </summary>
        /// <param name="cq"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public bool UpdateQuoteTemp(crm_quote cq, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            cq.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            cq.update_user_id = user_id;
            if (_dal.Update(cq))
            {
                new sys_oper_log_dal().Insert(new sys_oper_log()
                {
                    user_cate           = "用户",
                    user_id             = user_id,
                    name                = user.name,
                    phone               = user.mobile == null ? "" : user.mobile,
                    oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                    oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE,

                    oper_object_id = cq.id,// 操作对象id

                    oper_type_id = (int)OPER_LOG_TYPE.UPDATE,

                    oper_description = _dal.AddValue(cq),
                    remark           = "关联报价模板"
                });
            }
            return(true);
        }
Beispiel #12
0
        /// <summary>
        /// 设置为失活状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE NoActive(long id, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var data = GetSingel(id);

            if (data == null)
            {
                return(ERROR_CODE.ERROR);
            }
            if (Convert.ToInt32(data.status_id) == 0)
            {
                return(ERROR_CODE.NO_ACTIVATION);
            }
            data.status_id      = 0;
            data.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            data.update_user_id = user_id;
            if (!_dal.Update(data))
            {
                return(ERROR_CODE.ERROR);
            }
            return(ERROR_CODE.SUCCESS);
        }
Beispiel #13
0
        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="data"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE Insert(d_account_classification data, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var cla = _dal.FindSignleBySql <d_account_classification>($"select * from d_account_classification where name='{data.name}' and delete_time=0");

            if (cla != null)
            {
                return(ERROR_CODE.EXIST);
            }
            data.create_time    = data.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            data.create_user_id = user_id;
            _dal.Insert(data);
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = "",
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ACCOUNTCLASS, //
                oper_object_id      = data.id,                             // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                oper_description    = _dal.AddValue(data),
                remark              = "新增客户类别信息"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志
            return(ERROR_CODE.SUCCESS);
        }
Beispiel #14
0
        /// <summary>
        /// 从全部当前激活的合同中排除
        /// </summary>
        /// <param name="id"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE Exclude(long id, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var exc      = new ctt_contract_dal();
            var exc_role = new ctt_contract_exclusion_role_dal();
            ctt_contract_exclusion_role role = new ctt_contract_exclusion_role();

            var excc = exc.FindListBySql <ctt_contract>($"select * from ctt_contract where status_id = 1 and end_date> CURDATE() and delete_time = 0");

            if (excc.Count > 0)
            {
                foreach (var i in excc)
                {
                    var exccrole = exc_role.FindListBySql <ctt_contract_exclusion_role>($"select * from ctt_contract_exclusion_role where role_id={id} and contract_id={i.id} and delete_time=0");
                    if (exccrole == null)
                    {
                        try
                        {
                            role.contract_id    = i.id;
                            role.id             = (int)(_dal.GetNextIdCom());
                            role.role_id        = id;
                            role.create_user_id = role.update_user_id = user_id;
                            role.create_time    = role.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                            exc_role.Insert(role);
                            var add_log = new sys_oper_log()
                            {
                                user_cate           = "用户",
                                user_id             = (int)user.id,
                                name                = user.name,
                                phone               = user.mobile == null ? "" : user.mobile,
                                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTRACT_EXCLUSTION_ROLE, //角色
                                oper_object_id      = role.id,                                         // 操作对象id
                                oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                                oper_description    = _dal.AddValue(role),
                                remark              = "新增合同例外因素--角色"
                            };                                      // 创建日志
                            new sys_oper_log_dal().Insert(add_log); // 插入日志
                        }
                        catch
                        {
                            return(ERROR_CODE.ERROR);
                        }
                    }
                }
            }
            else
            {
                return(ERROR_CODE.CONTRACT_NO_ACTIVE);
            }
            return(ERROR_CODE.SUCCESS);
        }
Beispiel #15
0
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="id"></param>
        /// <param name="user_id"></param>
        /// <param name="returnvalue"></param>
        /// <returns></returns>
        public ERROR_CODE Delete(long id, long user_id, out string returnvalue)
        {
            returnvalue = string.Empty;
            StringBuilder re   = new StringBuilder();
            var           user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }

            //工时、队列、合同、员工部门等
            //
            var res = new sys_resource_dal().FindListBySql <sys_resource>($"");

            if (res.Count > 0)
            {
                re.Append("角色不能被删除,因为它被以下对象引用:");
                int n = 1;
                foreach (var ii in res)
                {
                    re.Append("N" + (n++) + "\t\t" + ii.name + "\n");
                }
                returnvalue = re.ToString();
                return(ERROR_CODE.EXIST);
            }

            var data = _dal.FindById(id);

            if (data == null)
            {
                return(ERROR_CODE.ERROR);
            }
            data.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            data.delete_user_id = user_id;
            if (!_dal.Update(data))
            {
                return(ERROR_CODE.ERROR);
            }
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ROLE, //角色
                oper_object_id      = data.id,                     // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                oper_description    = _dal.AddValue(data),
                remark              = "删除角色信息"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志

            return(ERROR_CODE.SUCCESS);
        }
Beispiel #16
0
        /// <summary>
        /// 通过id删除
        /// </summary>
        /// <param name="id"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE Delete(long id, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var data = _dal.FindById(id);

            if (data == null)
            {
                return(ERROR_CODE.ERROR);
            }
            if (data.is_system > 0)
            {
                return(ERROR_CODE.SYSTEM);
            }
            var mar = new crm_account_dal().FindListBySql($"select * from crm_account where classification_id={id} and delete_time=0");

            if (mar.Count > 0)
            {
                foreach (var acc in mar)
                {
                    acc.classification_id = null;
                    acc.update_time       = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    acc.update_user_id    = user_id;
                    if (!new crm_account_dal().Update(acc))
                    {
                        return(ERROR_CODE.ERROR);
                    }
                }
            }
            data.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            data.delete_user_id = user_id;
            if (!_dal.Update(data))
            {
                return(ERROR_CODE.ERROR);
            }
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = "",
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ACCOUNTCLASS, //
                oper_object_id      = data.id,                             // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                oper_description    = _dal.AddValue(data),
                remark              = "删除客户类别信息"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志
            return(ERROR_CODE.SUCCESS);
        }
Beispiel #17
0
        public ERROR_CODE default_quote_template(long user_id, long id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                // 查询不到用户,用户丢失
                return(ERROR_CODE.PARAMS_ERROR);
            }
            var sq  = _dal.FindById(id);
            var old = sq;

            if (sq == null)
            {
                return(ERROR_CODE.ERROR);
            }
            if (sq.is_default == 1)
            {
                return(ERROR_CODE.DEFAULT);
            }
            sys_quote_tmpl sqt = _dal.FindSignleBySql <sys_quote_tmpl>($"select * from sys_quote_tmpl where is_default=1 and cate_id='{sq.cate_id}'");

            if (sqt != null)
            {
                sqt.is_default     = 0;
                sqt.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                sqt.update_user_id = user_id;
                if (_dal.Update(sqt) == false)
                {
                    return(ERROR_CODE.ERROR);
                }
            }
            sq.is_default     = 1;
            sq.update_user_id = user_id;
            sq.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            if (_dal.Update(sq) == false)
            {
                return(ERROR_CODE.ERROR);
            }
            var add_account_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE_TEMP,
                oper_object_id      = sq.id,// 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = _dal.CompareValue(old, sq),
                remark              = "修改报价模板"
            };                                              // 创建日志

            new sys_oper_log_dal().Insert(add_account_log); // 插入日志
            return(ERROR_CODE.SUCCESS);
        }
Beispiel #18
0
        public bool SetPrimaryQuote(long user_id, long quote_id)
        {
            var user  = UserInfoBLL.GetUserInfo(user_id);
            var quote = new crm_quote_dal().GetQuote(quote_id);

            if (quote != null)
            {
                var quoteList    = new crm_quote_dal().GetQuoteByWhere($" and opportunity_id = {quote.opportunity_id} ");
                var primaryQuote = quoteList.FirstOrDefault(_ => _.is_primary_quote == 1);
                if (primaryQuote != null && quote.id != primaryQuote.id)
                {
                    primaryQuote.is_primary_quote = null;
                    primaryQuote.update_user_id   = user.id;
                    primaryQuote.update_time      = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);

                    var oldPrimaryQuote = new QuoteBLL().GetQuote(primaryQuote.id);

                    new sys_oper_log_dal().Insert(new sys_oper_log()
                    {
                        user_cate           = "用户",
                        user_id             = (int)user.id,
                        name                = user.name,
                        phone               = user.mobile == null ? "" : user.mobile,
                        oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                        oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE,
                        oper_object_id      = primaryQuote.id,// 操作对象id
                        oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                        oper_description    = _dal.CompareValue(oldPrimaryQuote, primaryQuote),
                        remark              = "更改主报价为报价"
                    });
                    new crm_quote_dal().Update(primaryQuote);

                    quote.is_primary_quote = 1;
                    quote.update_user_id   = user.id;
                    quote.update_time      = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    new sys_oper_log_dal().Insert(new sys_oper_log()
                    {
                        user_cate           = "用户",
                        user_id             = (int)user.id,
                        name                = user.name,
                        phone               = user.mobile == null ? "" : user.mobile,
                        oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                        oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE,
                        oper_object_id      = quote.id,// 操作对象id
                        oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                        oper_description    = _dal.CompareValue(new crm_quote_dal().GetQuote(quote_id), quote),
                        remark              = "更改报价为主报价"
                    });
                    new crm_quote_dal().Update(quote);
                }
                return(true);
            }
            return(false);
        }
Beispiel #19
0
        /// <summary>
        /// 修改销售订单
        /// </summary>
        /// <param name="sale_order"></param>
        /// <param name="udfValue"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE EditSaleOrder(crm_sales_order sale_order, List <UserDefinedFieldValue> udfValue, long user_id)
        {
            if (sale_order.status_id == 0 || sale_order.contact_id == 0 || sale_order.owner_resource_id == 0)
            {
                return(ERROR_CODE.PARAMS_ERROR);
            }
            if (sale_order.begin_date.ToString("yyyy-MM-dd") == "0001-01-01" || sale_order.end_date == null || ((DateTime)sale_order.end_date).ToString("yyyy-MM-dd") == "0001-01-01")
            {
                return(ERROR_CODE.PARAMS_ERROR);
            }
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                return(ERROR_CODE.USER_NOT_FIND);
            }

            var old_sale_order = new crm_sales_order_dal().GetSingleSalesOrderByWhere($" and id= {sale_order.id}");

            sale_order.oid            = old_sale_order.oid;
            sale_order.opportunity_id = old_sale_order.opportunity_id;
            sale_order.create_user_id = old_sale_order.create_user_id;
            sale_order.create_time    = old_sale_order.create_time;
            sale_order.update_user_id = user.id;
            sale_order.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            _dal.Update(sale_order);

            new sys_oper_log_dal().Insert(new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = user_id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.SALE_ORDER,
                oper_object_id      = sale_order.id,// 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = _dal.CompareValue(old_sale_order, sale_order),
                remark              = "修改销售订单"
            });



            // 销售订单自定义

            var udf_sales_list = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.SALES);

            new UserDefinedFieldsBLL().UpdateUdfValue(DicEnum.UDF_CATE.SALES, udf_sales_list, sale_order.id, udfValue, user, OPER_LOG_OBJ_CATE.SALE_ORDER);


            return(ERROR_CODE.SUCCESS);
        }
Beispiel #20
0
        /// <summary>
        /// 删除报价
        /// </summary>
        /// <param name="quote_id"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public bool DeleteQuote(long quote_id, long user_id)
        {
            // todo 报价如果关联了销售订单,则不可删除


            var quote = _dal.GetQuote(quote_id);

            if (quote != null)
            {
                var user = UserInfoBLL.GetUserInfo(user_id);
                if (user != null)
                {
                    quote.delete_user_id = user_id;
                    quote.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    _dal.Update(quote);
                    new sys_oper_log_dal().Insert(new sys_oper_log()
                    {
                        user_cate           = "用户",
                        user_id             = (int)user.id,
                        name                = user.name,
                        phone               = user.mobile == null ? "" : user.mobile,
                        oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                        oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE,
                        oper_object_id      = quote.id,// 操作对象id
                        oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                        oper_description    = _dal.AddValue(quote),
                        remark              = "删除报价"
                    });

                    var quoteItemList = new crm_quote_item_dal().GetQuoteItems(" and quote_id = " + quote.id);   // 删除报价的同时,删除报价下的所有报价项
                    if (quoteItemList != null && quoteItemList.Count > 0)
                    {
                        var quoteItemBLL = new QuoteItemBLL();
                        quoteItemList.ForEach(_ =>
                        {
                            //_.delete_user_id = user_id;
                            //_.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                            quoteItemBLL.DeleteQuoteItem(_.id, user.id);
                        });
                    }
                    return(true);
                }
            }

            return(false);
        }
Beispiel #21
0
        /// <summary>
        /// 激活安全等级
        /// </summary>
        /// <param name="user_id"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public ERROR_CODE ActiveSecurityLevel(long user_id, int id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var old = GetSecurityLevel(id);
            // sys_security_level sclev = new sys_security_level();
            var seclev = old;

            if (seclev == null)
            {
                return(ERROR_CODE.ERROR);
            }
            if (seclev.is_active != null && seclev.is_active > 0)
            {
                return(ERROR_CODE.ACTIVATION);//已经激活
            }
            seclev.is_active      = 1;
            seclev.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            seclev.update_user_id = user_id;
            if (ss_dal.Update(seclev) == false)
            {
                return(ERROR_CODE.ERROR);//更新激活状态失败
            }

            var add_account_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.SECURITY_LEVEL,
                oper_object_id      = seclev.id,// 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = ss_dal.CompareValue(old, seclev),
                remark              = "修改权限点关联模板"
            };                                              // 创建日志

            new sys_oper_log_dal().Insert(add_account_log); // 插入日志

            return(ERROR_CODE.SUCCESS);
        }
Beispiel #22
0
        public ERROR_CODE active_quote_template(long user_id, long id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                // 查询不到用户,用户丢失
                return(ERROR_CODE.PARAMS_ERROR);
            }
            var temp = _dal.FindById(id);
            var old  = temp;

            if (temp == null)
            {
                return(ERROR_CODE.ERROR);
            }
            if (temp.is_active > 0)
            {
                return(ERROR_CODE.ACTIVATION);
            }
            temp.is_active      = 1;
            temp.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            temp.update_user_id = user_id;
            if (_dal.Update(temp) == false)
            {
                return(ERROR_CODE.ERROR);
            }
            var add_account_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE_TEMP,
                oper_object_id      = temp.id,// 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = _dal.CompareValue(old, temp),
                remark              = "修改报价模板"
            };                                              // 创建日志

            new sys_oper_log_dal().Insert(add_account_log); // 插入日志

            return(ERROR_CODE.SUCCESS);
        }
Beispiel #23
0
        /// <summary>
        /// 报价模板的删除
        /// </summary>
        /// 报价模板
        public ERROR_CODE quote_template_delete(long user_id, long id)
        {
            sys_quote_tmpl sqt = GetQuoteTemplate(id);

            if (sqt != null)
            {
                if (sqt.is_system == 1 || sqt.is_custom == 1 || sqt.is_default == 1)
                {
                    return(ERROR_CODE.ERROR);//以下模板不能删除:
                }
                else
                {
                    sqt.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    sqt.delete_user_id = id;
                    _dal.Update(sqt);


                    #region 添加日志
                    var user = UserInfoBLL.GetUserInfo(user_id);
                    if (user == null)
                    {
                        // 查询不到用户,用户丢失
                        return(ERROR_CODE.USER_NOT_FIND);
                    }
                    var add_account_log = new sys_oper_log()
                    {
                        user_cate           = "用户",
                        user_id             = user.id,
                        name                = "",
                        phone               = user.mobile == null ? "" : user.mobile,
                        oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                        oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE_TEMP,
                        oper_object_id      = sqt.id,// 操作对象id
                        oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                        oper_description    = _dal.AddValue(sqt),
                        remark              = "删除报价模板"
                    };                                              // 创建日志
                    new sys_oper_log_dal().Insert(add_account_log); // 插入日志
                    #endregion
                    return(ERROR_CODE.SUCCESS);
                }
            }
            return(ERROR_CODE.ERROR);//获取数据失败,不能删除
        }
Beispiel #24
0
        public bool UpdateContacts(string updateIds, string phone, string fax, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                return(false);
            }
            var con_list    = updateIds.Split(',');
            var contactList = _dal.GetContactByIds(updateIds);

            if (contactList != null && contactList.Count > 0)
            {
                foreach (var item in con_list)
                {
                    var contact = new crm_contact_dal().FindById(Convert.ToInt64(item));   // 获取到对应的联系人信息
                    if (contact != null)
                    {
                        contact.phone          = phone;
                        contact.fax            = fax;
                        contact.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                        contact.update_user_id = user.id;
                        new crm_contact_dal().Update(contact);                   // 修改联系人
                        new sys_oper_log_dal().Insert(new sys_oper_log()
                        {
                            user_cate           = "用户",
                            user_id             = user.id,
                            name                = user.name,
                            phone               = user.mobile == null ? "" : user.mobile,
                            oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                            oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTACTS,
                            oper_object_id      = contact.id,
                            oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                            oper_description    = _dal.CompareValue(contactList.FirstOrDefault(_ => _.id == contact.id), contact),
                            remark              = "修改联系人电话或传真",
                        });    // 插入更改日志
                    }
                }
            }

            return(true);
        }
Beispiel #25
0
        /// <summary>
        /// 停用该角色
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ERROR_CODE NoAction(long id, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var data = GetOneData((int)id);
            var old  = data;

            if (data != null && data.is_active == 0)
            {
                return(ERROR_CODE.NO_ACTIVATION);
            }
            if (data == null)
            {
                return(ERROR_CODE.ERROR);
            }
            data.is_active      = 0;
            data.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            data.update_user_id = user.id;
            if (!_dal.Update(data))
            {
                return(ERROR_CODE.ERROR);
            }
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ROLE, //角色
                oper_object_id      = data.id,                     // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = _dal.CompareValue(old, data),
                remark              = "停用角色信息"
            };          // 创建日志

            return(ERROR_CODE.SUCCESS);
        }
Beispiel #26
0
        public ERROR_CODE Update(sys_role role, long user_id)
        {
            var old = GetOneData((int)role.id);

            role.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            role.update_user_id = user.id;
            var ro = _dal.FindSignleBySql <sys_role>($"select * from sys_role where name='{role.name}' and delete_time=0 ");

            if (ro != null && ro.id != role.id)
            {
                return(ERROR_CODE.EXIST);
            }

            if (_dal.Update(role) == false)
            {
                return(ERROR_CODE.ERROR);
            }
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ROLE, //角色
                oper_object_id      = role.id,                     // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = _dal.CompareValue(old, role),
                remark              = "修改角色"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志
            return(ERROR_CODE.SUCCESS);
        }
Beispiel #27
0
        public ERROR_CODE copy_quote_template(long user_id, ref long id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                // 查询不到用户,用户丢失
                return(ERROR_CODE.PARAMS_ERROR);
            }
            var sq = _dal.FindById(id);

            if (sq == null)
            {
                return(ERROR_CODE.ERROR);
            }
            sq.is_default     = 0;
            sq.is_system      = 0;
            sq.oid            = 0;
            id                = sq.id = (int)(_dal.GetNextIdCom());
            sq.name           = "(copy of)" + sq.name + Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            sq.create_time    = sq.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            sq.create_user_id = sq.update_user_id = user_id;
            _dal.Insert(sq);
            var add_account_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE_TEMP,
                oper_object_id      = sq.id,// 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                oper_description    = _dal.AddValue(sq),
                remark              = "修改报价模板"
            };                                              // 创建日志

            new sys_oper_log_dal().Insert(add_account_log); // 插入日志
            return(ERROR_CODE.SUCCESS);
        }
Beispiel #28
0
        public ERROR_CODE Update(sys_department sd, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var de  = _dal.FindSignleBySql <sys_department>($"select * from  sys_department where name='{sd.name}' and delete_time=0");
            var old = _dal.FindSignleBySql <sys_department>($"select * from  sys_department where id={sd.id} and delete_time=0");

            if (de != null && de.id != sd.id)
            {
                return(ERROR_CODE.EXIST);
            }
            sd.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            sd.update_user_id = user_id;
            sd.cate_id        = (int)DEPARTMENT_CATE.DEPARTMENT;

            var add_account_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.DEPARTMENT, //部门
                oper_object_id      = sd.id,                             // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = _dal.CompareValue(old, sd),
                remark              = "修改部门信息"
            };                                              // 创建日志

            new sys_oper_log_dal().Insert(add_account_log); // 插入日志
            if (!_dal.Update(sd))
            {
                return(ERROR_CODE.ERROR);
            }
            return(ERROR_CODE.SUCCESS);
        }
Beispiel #29
0
        public ERROR_CODE DeleteInventory(long id, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            ivt_warehouse_product_dal inv_dal = new ivt_warehouse_product_dal();
            var inv = inv_dal.FindNoDeleteById(id);

            if (inv == null)
            {
                return(ERROR_CODE.ERROR);
            }
            inv.delete_user_id = user_id;
            inv.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            if (!inv_dal.Update(inv))
            {
                return(ERROR_CODE.ERROR);
            }
            //操作日志
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.WAREHOUSE_PRODUCT, //
                oper_object_id      = inv.id,                                   // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                oper_description    = _dal.AddValue(inv),
                remark              = "删除产品库存信息"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志

            return(ERROR_CODE.SUCCESS);
        }
Beispiel #30
0
        public ERROR_CODE UpdateSecurityLevel(sys_security_level seclev, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var older = GetSecurityLevel(seclev.id);
            var old   = GetSecurityLevel(seclev.id);

            old.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            old.update_user_id = user_id;
            old.name           = seclev.name;
            old.is_active      = seclev.is_active;
            bool k = new sys_security_level_dal().Update(old);

            if (k == false)
            {
                return(ERROR_CODE.ERROR);
            }
            var add_account_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.SECURITY_LEVEL,
                oper_object_id      = seclev.id,// 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = new sys_security_level_dal().CompareValue(old, older),
                remark              = "修改权限点关联模板"
            };                                              // 创建日志

            new sys_oper_log_dal().Insert(add_account_log); // 插入日志

            return(ERROR_CODE.SUCCESS);
        }