Пример #1
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);
        }
Пример #2
0
        /// <summary>
        /// 获取配置项相关详情数据
        /// </summary>
        private void GetInsProDetail(HttpContext context)
        {
            var insProId = context.Request.QueryString["insProId"];

            if (!string.IsNullOrEmpty(insProId))
            {
                var insPr = new crm_installed_product_dal().FindNoDeleteById(long.Parse(insProId));
                if (insPr != null)
                {
                    string name        = "";
                    string contactName = "";
                    string contactId   = "";
                    string insTime     = "";
                    string insUser     = "";
                    string insWarnTime = "";  // 保修期
                    string vendorId    = "";
                    string vendorName  = "";
                    string insService  = "";
                    int    relateNum   = 0;    // 相关配置项
                    var    thisPro     = new ivt_product_dal().FindNoDeleteById(insPr.product_id);
                    if (thisPro != null)
                    {
                        name = thisPro.name;
                    }
                    if (insPr.contact_id != null)
                    {
                        var contact = new crm_contact_dal().FindNoDeleteById((long)insPr.contact_id);
                        if (contact != null)
                        {
                            contactId   = contact.id.ToString();
                            contactName = contact.name;
                        }
                    }
                    if (insPr.installed_resource_id != null)
                    {
                        var insRes = new sys_resource_dal().FindNoDeleteById((long)insPr.installed_resource_id);
                        if (insRes != null)
                        {
                            insUser = insRes.name;
                        }
                    }
                    if (insPr.vendor_account_id != null)
                    {
                        var thisVnedor = new CompanyBLL().GetCompany((long)insPr.vendor_account_id);
                        if (thisVnedor != null)
                        {
                            vendorId   = thisVnedor.id.ToString();
                            vendorName = thisVnedor.name;
                        }
                    }
                    insTime = Tools.Date.DateHelper.ConvertStringToDateTime(insPr.create_time).ToString("yyyy-MM-dd");



                    context.Response.Write(new Tools.Serialize().SerializeJson(new { id = insPr.id, name = name, contactId = contactId, contactName = contactName, insTime = insTime, insUser = insUser, insWarnTime = insWarnTime, vendorId = vendorId, vendorName = vendorName, insService = insService, relateNum = relateNum }));
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 根据属性名称获取到该类的value
        /// </summary>
        /// <param name="context"></param>
        /// <param name="iProduct_id"></param>
        /// <param name="propertyName"></param>
        public void GetIProductProperty(HttpContext context, long iProduct_id, string propertyName)
        {
            var iProduct = new crm_installed_product_dal().GetInstalledProduct(iProduct_id);

            if (iProduct != null)
            {
                context.Response.Write(BaseDAL <Core.crm_account> .GetObjectPropertyValue(iProduct, propertyName));
            }
        }
Пример #4
0
 /// <summary>
 /// 删除服务包相关,不能删除时,返回所有不能删除相关对象数量
 /// </summary>
 public bool DeleteServiceBundle(long serviceId, long userId, ref string faileReason)
 {
     try
     {
         var isbDal        = new ivt_service_bundle_dal();
         var thisSerBundle = isbDal.FindNoDeleteById(serviceId);
         if (thisSerBundle == null)
         {
             return(true);
         }
         var conSerList = new ctt_contract_service_dal().getContractByServiceId(thisSerBundle.id);
         if (conSerList != null && conSerList.Count > 0)
         {
             faileReason += $"{conSerList.Count} 合同\n";
         }
         var quoteItemList = new crm_quote_item_dal().GetItemByObjId(thisSerBundle.id);
         if (quoteItemList != null && quoteItemList.Count > 0)
         {
             faileReason += $"{quoteItemList.Count} 报价项\n";
         }
         var labourList = new sdk_work_entry_dal().GetListByService(thisSerBundle.id);
         if (labourList != null && labourList.Count > 0)
         {
             faileReason += $"{labourList.Count} 工时\n";
         }
         var insProList = new crm_installed_product_dal().GetInsListBySerBunId(thisSerBundle.id);
         if (insProList != null && insProList.Count > 0)
         {
             faileReason += $"{insProList.Count} 配置项\n";
         }
         if (!string.IsNullOrEmpty(faileReason))
         {
             return(false);
         }
         else
         {
             var isbsDal = new ivt_service_bundle_service_dal();
             var serList = GetServiceListByServiceBundleId(thisSerBundle.id);
             if (serList != null && serList.Count > 0)
             {
                 serList.ForEach(_ => {
                     isbsDal.Delete(_);
                 });
             }
             isbDal.SoftDelete(thisSerBundle, userId);
             OperLogBLL.OperLogDelete <ivt_service_bundle>(thisSerBundle, thisSerBundle.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE_BUNDLE, "删除服务包");
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Пример #5
0
        /// <summary>
        /// 获取到配置项信息
        /// </summary>
        private void GetInsProInfo(HttpContext context)
        {
            var insProId = context.Request.QueryString["insProId"];

            if (!string.IsNullOrEmpty(insProId))
            {
                var insPr = new crm_installed_product_dal().FindNoDeleteById(long.Parse(insProId));
                if (insPr != null)
                {
                    context.Response.Write(new Tools.Serialize().SerializeJson(insPr));
                }
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var quote_id = Request.QueryString["quote_id"];

            if (!string.IsNullOrEmpty(quote_id))
            {
                quote = new crm_quote_dal().FindNoDeleteById(long.Parse(quote_id));
            }
            if (quote != null)
            {
                // 如何获取到已经生成配置项 的报价项和为生成配置项的报价项

                // 1 获取产品相关报价项
                // 2 根据产品报价项的数量,去获取相应的配置项数量,数量不足时,将剩余的报价项放入展示的报价项中
                // 3 成本同理

                var cqiDal = new crm_quote_item_dal();
                var cipDal = new crm_installed_product_dal();
                #region 获取相应的产品报价项
                var productList = cqiDal.GetItemByType(quote.id, (int)DTO.DicEnum.QUOTE_ITEM_TYPE.PRODUCT);
                if (productList != null && productList.Count > 0)
                {
                    isShowProduct = true;

                    foreach (var item in productList)
                    {
                        if (item.quantity != null && item.quote_id != null)
                        {
                            var insProList = cipDal.GetInsProByQuoteId((long)item.id, (long)item.quantity);
                            int num        = (int)item.quantity; // 获取多少次 这个报价项
                            if (insProList != null && insProList.Count > 0)
                            {
                                num = (int)item.quantity - insProList.Count;
                                var itemList = cqiDal.GetItemByNum(item.id, insProList.Count);
                                if (itemList != null && itemList.Count > 0)
                                {
                                    ExistProductItemList.AddRange(itemList);
                                }
                            }
                            if (num > 0)
                            {
                                var itemList = cqiDal.GetItemByNum(item.id, num);
                                if (itemList != null && itemList.Count > 0)
                                {
                                    productItemList.AddRange(itemList);
                                }
                            }
                        }
                    }
                }
                #endregion


                #region 获取相应的成本报价项
                var chargeList = cqiDal.GetItemByType(quote.id, (int)DTO.DicEnum.QUOTE_ITEM_TYPE.DEGRESSION);
                if (chargeList != null && chargeList.Count > 0)
                {
                    isShowCharge = true;

                    foreach (var item in chargeList)
                    {
                        if (item.quantity != null && item.quote_id != null)
                        {
                            var insProList = cipDal.GetInsProByQuoteId((long)item.id, (long)item.quantity);
                            int num        = (int)item.quantity; // 获取多少次 这个报价项
                            if (insProList != null && insProList.Count > 0)
                            {
                                num = (int)item.quantity - insProList.Count;
                                var itemList = cqiDal.GetItemByNum(item.id, insProList.Count);
                                if (itemList != null && itemList.Count > 0)
                                {
                                    ExistChargeItemList.AddRange(itemList);
                                }
                            }
                            if (num > 0)
                            {
                                var itemList = cqiDal.GetItemByNum(item.id, num);
                                if (itemList != null && itemList.Count > 0)
                                {
                                    chargeItemList.AddRange(itemList);
                                }
                            }
                        }
                    }
                }

                #endregion

                if (!IsPostBack)
                {
                    rbBuyDate.Enabled = false;
                }
            }
        }
Пример #7
0
        /// <summary>
        /// 产品删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ERROR_CODE DeleteProduct(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);
            }
            StringBuilder result = new StringBuilder();

            result.Append("产品不能被删除,因为它被以下对象引用\n");
            var opportunitylist       = new crm_opportunity_dal().FindListBySql($"select * from crm_opportunity where primary_product_id={id} and delete_time=0");
            var installed_productlist = new crm_installed_product_dal().FindListBySql($"select * from crm_installed_product where product_id={id} and delete_time=0");
            var warehouse_productlist = new ivt_warehouse_product_dal().FindListBySql($"select * from ivt_warehouse_product where product_id={id} and delete_time=0");
            var contract_costlist     = new ctt_contract_cost_dal().FindListBySql($"select * from ctt_contract_cost where product_id={id} and delete_time=0");
            int n = 1;

            if (opportunitylist.Count > 0)
            {
                result.Append($"{opportunitylist.Count} 商机\n");
                //foreach (var op in opportunitylist) {

                //    result.Append("N"+(n++)+"   "+op.id + "\n");
                //}
            }
            if (installed_productlist.Count > 0)
            {
                result.Append($"{installed_productlist.Count} 配置项\n");
                //foreach (var op in installed_productlist)
                //{
                //    result.Append("N" + (n++) + "  " + op.id + "\n");
                //}
            }
            if (warehouse_productlist.Count > 0)
            {
                result.Append($"{warehouse_productlist.Count} 库存\n");
                //foreach (var op in warehouse_productlist)
                //{
                //    result.Append("N" + (n++) + "  " + op.id + "\n");
                //}
            }
            if (contract_costlist.Count > 0)
            {
                result.Append($"{contract_costlist.Count} 工单\n");
                //foreach (var op in contract_costlist)
                //{
                //    result.Append("N" + (n++) + "  " + op.id + "\n");
                //}
            }
            if (contract_costlist.Count > 0 || warehouse_productlist.Count > 0 || installed_productlist.Count > 0 || opportunitylist.Count > 0)
            {
                returnvalue = result.ToString();
                return(ERROR_CODE.EXIST);
            }
            var product_del = _dal.FindSignleBySql <ivt_product>($"select * from ivt_product where id={id} and delete_time=0");

            if (product_del == null)
            {
                return(ERROR_CODE.ERROR);
            }
            product_del.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            product_del.delete_user_id = user.id;
            if (!_dal.Update(product_del))
            {
                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.PRODUCT, //
                oper_object_id      = product_del.id,                 // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                oper_description    = _dal.AddValue(product_del),
                remark              = "删除产品信息"
            };                                      // 创建日志

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


            var del = _dal.FindSignleBySql <ivt_product>($"select * from ivt_product where id={id} and delete_time=0");

            return(ERROR_CODE.SUCCESS);
        }
Пример #8
0
        /// <summary>
        /// 新增附件
        /// </summary>
        /// <param name="objType">对象类型</param>
        /// <param name="objId">对象id</param>
        /// <param name="typeId">附件类型</param>
        /// <param name="title">附件名</param>
        /// <param name="attLink">附件内容</param>
        /// <param name="fileName">上传的文件名</param>
        /// <param name="fileSaveName">文件保存服务器的名称</param>
        /// <param name="contentType">文件类型</param>
        /// <param name="size">文件大小</param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool AddAttachment(int objType, long objId, int typeId, string title, string attLink, string fileName, string fileSaveName, string contentType, int size, long userId, string pubTypeId = "")
        {
            com_attachment att = new com_attachment();


            att.object_type_id = objType;
            att.object_id      = objId;

            // 备注和附件的下级备注和附件不能再添加附件
            if (objType == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES)
            {
                var note = new com_activity_dal().FindById(objId);
                if (note.object_type_id == (int)DicEnum.OBJECT_TYPE.NOTES)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES;
                    att.object_id      = note.object_id;
                }
                else if (note.object_type_id == (int)DicEnum.OBJECT_TYPE.ATTACHMENT)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT;
                    att.object_id      = note.object_id;
                }
            }
            else if (objType == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT)
            {
                var attachment = dal.FindById(objId);
                if (attachment.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES;
                    att.object_id      = attachment.object_id;
                }
                else if (attachment.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT;
                    att.object_id      = attachment.object_id;
                }
            }
            else if (objType == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.LABOUR)
            {
                var labour = new sdk_work_entry_dal().FindById(objId);
                if (labour.parent_id != null)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.LABOUR;
                    att.object_id      = (long)labour.parent_id;
                }
                else if (labour.parent_attachment_id != null)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT;
                    att.object_id      = (long)labour.parent_attachment_id;
                }
                else if (labour.parent_note_id != null)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES;
                    att.object_id      = (long)labour.parent_note_id;
                }
            }

            if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT)
            {
                var attachment = dal.FindById(att.object_id);
                att.account_id = attachment.account_id;
                att.parent_id  = attachment.id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES)
            {
                var note = new com_activity_dal().FindById(att.object_id);
                att.account_id = note.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.OPPORTUNITY)
            {
                var opp = new crm_opportunity_dal().FindById(att.object_id);
                att.account_id = opp.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.SALES_ORDER)
            {
                var so  = new crm_sales_order_dal().FindById(att.object_id);
                var opp = new crm_opportunity_dal().FindById(so.opportunity_id);
                att.account_id = opp.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.CONTRACT)
            {
                var contract = new ctt_contract_dal().FindById(att.object_id);
                att.account_id = contract.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.COMPANY)
            {
                att.account_id = att.object_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.PROJECT)
            {
                var project = new pro_project_dal().FindNoDeleteById(att.object_id);
                att.account_id = project.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.EXPENSE_REPORT)
            {
                // 从报表添加附件 - 默认使用声联(oid=0) 的客户
                var defaultAccount = new CompanyBLL().GetDefaultAccount();
                att.account_id = defaultAccount.id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.TASK)
            {
                var task = new sdk_task_dal().FindNoDeleteById(att.object_id);
                if (task != null)
                {
                    att.account_id = task.account_id;
                    #region 更新客户最后活动时间
                    crm_account thisAccount = new CompanyBLL().GetCompany(task.account_id);
                    if (thisAccount != null)
                    {
                        thisAccount.last_activity_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); new CompanyBLL().EditAccount(thisAccount, userId);
                    }
                    #endregion
                }
                if (!string.IsNullOrEmpty(pubTypeId))
                {
                    att.publish_type_id = int.Parse(pubTypeId);
                }
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.LABOUR)
            {
                var labour = new sdk_work_entry_dal().FindNoDeleteById(att.object_id);
                if (labour == null)
                {
                    return(false);
                }
                var ticket = new sdk_task_dal().FindNoDeleteById(labour.task_id);
                if (ticket == null)
                {
                    return(false);
                }
                att.account_id = ticket.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.KNOWLEDGE)
            {
                var thisArt = new sdk_kb_article_dal().FindNoDeleteById(att.object_id);
                if (thisArt == null)
                {
                    return(false);
                }
                att.account_id = thisArt.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.RESOURCE)
            {
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.CONFIGITEM)
            {
                crm_installed_product insPro = new crm_installed_product_dal().FindNoDeleteById(att.object_id);
                if (insPro == null)
                {
                    return(false);
                }
                att.account_id = insPro.account_id;
            }
            else
            {
                return(false);
            }

            att.id             = dal.GetNextIdCom();
            att.create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
            att.create_user_id = userId;
            att.update_time    = att.create_time;
            att.update_user_id = userId;
            att.title          = title;
            att.type_id        = typeId;
            if (typeId == (int)DicEnum.ATTACHMENT_TYPE.FILE_LINK ||
                typeId == (int)DicEnum.ATTACHMENT_TYPE.FOLDER_LINK)
            {
                att.uncpath  = attLink;
                att.filename = @"file://" + attLink;
            }
            else if (typeId == (int)DicEnum.ATTACHMENT_TYPE.URL)
            {
                if (attLink.IndexOf(@"http://") == 0)
                {
                    attLink      = attLink.Remove(0, 7);
                    att.urlpath  = attLink;
                    att.filename = @"http://" + attLink;
                }
                else if (attLink.IndexOf(@"https://") == 0)
                {
                    attLink      = attLink.Remove(0, 8);
                    att.urlpath  = attLink;
                    att.filename = @"https://" + attLink;
                }
                else
                {
                    att.urlpath  = attLink;
                    att.filename = @"http://" + attLink;
                }
            }
            else if (typeId == (int)DicEnum.ATTACHMENT_TYPE.ATTACHMENT)
            {
                att.href         = fileSaveName;
                att.filename     = fileName;
                att.sizeinbyte   = size;
                att.content_type = contentType;
            }
            else
            {
                return(false);
            }

            dal.Insert(att);
            OperLogBLL.OperLogAdd <com_attachment>(att, att.id, userId, DicEnum.OPER_LOG_OBJ_CATE.ATTACHMENT, "新增附件");
            return(true);
        }
Пример #9
0
        /// <summary>
        ///  //删除操作
        /// </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);
            }
            var udf_data = _dal.FindById(Convert.ToInt64(data.ext1));
            crm_installed_product_dal dal1 = new crm_installed_product_dal();
            ivt_product_dal           dal2 = new ivt_product_dal();

            var installed_product = dal1.FindListBySql($"select * from crm_installed_product where cate_id={id} and delete_time=0");
            var product           = dal2.FindListBySql($"select * from ivt_product where installed_product_cate_id={id} and delete_time=0");
            var product_cate      = _dal.FindListBySql($"select * from d_general where ext1='{id.ToString()}' and delete_time=0");

            if (installed_product.Count > 0)
            {
                foreach (var i in installed_product)
                {
                    i.cate_id        = 0;
                    i.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    i.update_user_id = user_id;
                    if (dal1.Update(i))
                    {
                        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.CONFIGURAITEM, //
                            oper_object_id      = i.id,                                 // 操作对象id
                            oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                            oper_description    = _dal.AddValue(i),
                            remark              = "修改产品配置项"
                        };                                      // 创建日志
                        new sys_oper_log_dal().Insert(add_log); // 插入日志
                    }
                }
            }
            if (product.Count > 0)
            {
                foreach (var i in product)
                {
                    i.installed_product_cate_id = null;
                    i.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    i.update_user_id = user_id;
                    if (dal2.Update(i))
                    {
                        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.PRODUCT, //
                            oper_object_id      = i.id,                           // 操作对象id
                            oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                            oper_description    = _dal.AddValue(i),
                            remark              = "修改产品配置项"
                        };                                      // 创建日志
                        new sys_oper_log_dal().Insert(add_log); // 插入日志
                    }
                }
            }
            if (product_cate.Count > 0)
            {
                foreach (var i in product_cate)
                {
                    i.ext1           = null;
                    i.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    i.update_user_id = user_id;
                    if (_dal.Update(i))
                    {
                        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.General_Code, //
                            oper_object_id      = i.id,                                // 操作对象id
                            oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                            oper_description    = _dal.AddValue(i),
                            remark              = "修改配置项种类"
                        };                                      // 创建日志
                        new sys_oper_log_dal().Insert(add_log); // 插入日志
                    }
                }
            }

            long time = data.delete_time = udf_data.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);

            data.delete_user_id = udf_data.delete_user_id = user.id;
            try
            {
                int n = new sys_udf_group_field_dal().ExecuteSQL($"update sys_udf_group_field set delete_time='{time}' and delete_user_id='{user.id}' where group_id={udf_data.id}");
            }
            catch {
                return(ERROR_CODE.ERROR);
            }
            if (!_dal.Update(data))
            {
                return(ERROR_CODE.ERROR);
            }
            if (!_dal.Update(udf_data))
            {
                return(ERROR_CODE.ERROR);
            }

            return(ERROR_CODE.SUCCESS);
        }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var cid        = Request.QueryString["contract_id"];
                var project_id = Request.QueryString["project_id"];
                var ccid       = Request.QueryString["cost_id"];
                if (!string.IsNullOrEmpty(cid))
                {
                    contract = new ctt_contract_dal().FindNoDeleteById(long.Parse(cid));
                }
                if (!string.IsNullOrEmpty(project_id))
                {
                    thisProject = new pro_project_dal().FindNoDeleteById(long.Parse(project_id));
                }

                conCost = new ctt_contract_cost_dal().FindNoDeleteById(long.Parse(ccid));
                if (conCost != null)
                {
                    if (conCost.product_id != null)
                    {
                        product = new ivt_product_dal().FindNoDeleteById((long)conCost.product_id);
                    }
                    else
                    {
                        product = new ivt_product_dal().GetDefaultProduct();
                    }
                    if (conCost.quantity != null)
                    {
                        var thisSubList = new crm_installed_product_dal().GetInsProByCostId(conCost.id, (long)conCost.quantity);
                        int num         = (int)conCost.quantity;
                        if (thisSubList != null && thisSubList.Count > 0)
                        {
                            num          = (int)conCost.quantity - thisSubList.Count;
                            exisCostList = new ctt_contract_cost_dal().GetItemByNum(conCost.id, thisSubList.Count);
                        }
                        if (num > 0)
                        {
                            costList = new ctt_contract_cost_dal().GetItemByNum(conCost.id, num);
                        }
                    }
                    if (costList != null && costList.Count > 0)
                    {
                    }
                }
                if (conCost == null)
                {
                    Response.Write("<script>alert('未查询到成本');window.close();</script>");
                    return;
                }
                if (conCost.create_ci == 1)
                {
                    Response.Write("<script>alert('成本已创建配置项!');window.close();</script>");
                    return;
                }
            }
            catch (Exception)
            {
                Response.End();
            }
        }