Example #1
0
        /// <summary>
        /// 新增合同时添加服务包
        /// </summary>
        /// <param name="context"></param>
        /// <param name="id"></param>
        public void AddServiceBundle(HttpContext context, long id)
        {
            var           serBun          = new ivt_service_bundle_dal().FindById(id);
            string        txt             = "";
            decimal       pricePerPeriod  = 0;
            int           monthsPerPeriod = 1;
            List <object> result          = new List <object>();

            if (serBun == null)
            {
                result.Add(txt);
                result.Add(pricePerPeriod);

                context.Response.Write(new Tools.Serialize().SerializeJson(result));
                return;
            }

            // 获取供应商名称
            string vendorName = "";

            if (serBun.vendor_account_id != null)
            {
                var vendorDal  = new ivt_product_vendor_dal();
                var accountDal = new crm_account_dal();
                var vendor     = vendorDal.FindById((long)serBun.vendor_account_id);
                if (vendor.vendor_account_id != null)
                {
                    vendorName = accountDal.FindById((long)vendor.vendor_account_id).name;
                }
            }

            // 周期
            string period = "";

            if (serBun.period_type_id != null)
            {
                period = new GeneralBLL().GetGeneralName((int)serBun.period_type_id);
                if (serBun.unit_price == null)
                {
                    pricePerPeriod = 0;
                }
                else
                {
                    pricePerPeriod = (decimal)serBun.unit_price;
                }

                if (serBun.period_type_id == (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.QUARTER)
                {
                    monthsPerPeriod = 3;
                }
                if (serBun.period_type_id == (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.HALFYEAR)
                {
                    monthsPerPeriod = 6;
                }
                if (serBun.period_type_id == (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.YEAR)
                {
                    monthsPerPeriod = 12;
                }
            }

            string unitCost = "";

            if (serBun.unit_cost != null)
            {
                unitCost = "¥" + serBun.unit_cost.ToString();
            }

            txt += $"<tr id='service{serBun.id}'>";
            txt += $"<td style='white - space:nowrap; '><img src = '../Images/delete.png' onclick='RemoveServiceBundle({serBun.id})' alt = '' /></ td > ";
            txt += $"<td><span>{serBun.name}</span></td>";
            txt += $"<td nowrap>{vendorName}</td>";
            txt += $"<td nowrap><span>{period}</span><input type='hidden' id='period{serBun.id}' value='{monthsPerPeriod}' ></td>";
            txt += $"<td nowrap align='right'><span>{unitCost}</span></td>";
            txt += $"<td nowrap align='right'>" + $"<input type='text' onblur='CalcService()' id='price{serBun.id}' name='price{serBun.id}' value = '{pricePerPeriod}' >" + "</ td > ";
            txt += $"<td nowrap align='right'>" + $"<input type='text' onblur='CalcService()' id='num{serBun.id}' name='num{serBun.id}' value = '1' >" + "</ td > ";
            txt += $"<td nowrap align='right'>¥" + $"<input type='text' id='pricenum{serBun.id}' value = '{pricePerPeriod}' disabled >" + "</ td > ";
            txt += "</tr>";

            result.Add(txt);
            result.Add(pricePerPeriod);
            result.Add(serBun.id);
            result.Add(monthsPerPeriod);

            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
Example #2
0
        /// <summary>
        /// 修改更新产品和相关供应商信息
        /// </summary>
        /// <param name="product">产品</param>
        /// <param name="vendordata">供应商集合</param>
        /// <param name="udf">自定义字段值</param>
        /// <param name="user_id">操作用户</param>
        /// <returns></returns>
        public ERROR_CODE UpdateProductAndVendor(ivt_product product, VendorData vendordata, List <UserDefinedFieldValue> udf, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            //产品更新
            product.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            product.update_user_id = user_id;

            //唯一性校验
            var         propro    = _dal.FindSignleBySql <ivt_product>($"select * from ivt_product where name='{product.name}' and delete_time=0 ");
            ivt_product oldpropro = _dal.FindSignleBySql <ivt_product>($"select * from ivt_product where id='{product.id}' and delete_time=0 ");

            if (propro != null && product.id != propro.id)
            {
                return(ERROR_CODE.EXIST);
            }
            //更新日志
            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.id,// 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = _dal.CompareValue(oldpropro, product),
                remark              = "修改产品信息"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志
            if (!_dal.Update(product))
            {
                return(ERROR_CODE.ERROR);
            }
            //供应商更新
            foreach (var ve in vendordata.VENDOR)
            {
                ivt_product_vendor veve = new ivt_product_vendor();
                //删除
                if (ve.operate == 1)
                {
                    var de = _dal1.FindById(ve.id);
                    if (de != null)
                    {
                        de.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                        de.delete_user_id = user_id;
                        _dal1.Update(de);
                        var add_vendor_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_VENDOR,
                            oper_object_id      = veve.id,// 操作对象id
                            oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                            oper_description    = _dal1.AddValue(veve),
                            remark              = "删除供应商信息"
                        };                                             // 创建日志
                        new sys_oper_log_dal().Insert(add_vendor_log); // 插入日志
                    }
                }

                //更新
                if (ve.operate == 2)
                {
                    veve = _dal1.FindById(ve.id);
                    if (veve != null)
                    {
                        veve.update_time       = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                        veve.update_user_id    = user_id;
                        veve.product_id        = product.id;
                        veve.is_active         = ve.is_active;
                        veve.is_default        = ve.is_default;
                        veve.vendor_account_id = ve.vendor_account_id;
                        veve.vendor_cost       = ve.vendor_cost;
                        veve.vendor_product_no = ve.vendor_product_no;
                        var oldve = GetSingelVendor(veve.id);
                        _dal1.Update(veve);
                        var add_vendor_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_VENDOR,
                            oper_object_id      = veve.id,// 操作对象id
                            oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                            oper_description    = _dal1.CompareValue(oldve, veve),
                            remark              = "修改供应商信息"
                        };                                             // 创建日志
                        new sys_oper_log_dal().Insert(add_vendor_log); // 插入日志
                    }
                }

                //新增
                if (ve.operate == 3)
                {
                    veve.id                = (int)(_dal.GetNextIdCom());
                    veve.update_time       = veve.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    veve.create_user_id    = user_id;
                    veve.product_id        = product.id;
                    veve.is_active         = ve.is_active;
                    veve.is_default        = ve.is_default;
                    veve.vendor_account_id = ve.vendor_account_id;
                    veve.vendor_cost       = ve.vendor_cost;
                    veve.vendor_product_no = ve.vendor_product_no;
                    _dal1.Insert(veve);
                    var add_vendor_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_VENDOR,
                        oper_object_id      = veve.id,// 操作对象id
                        oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                        oper_description    = _dal1.AddValue(veve),
                        remark              = "新增供应商信息"
                    };                                             // 创建日志
                    new sys_oper_log_dal().Insert(add_vendor_log); // 插入日志
                }
            }

            var udfBll           = new UserDefinedFieldsBLL();
            var udf_contact_list = udfBll.GetUdf(DicEnum.UDF_CATE.PRODUCTS); // 产品的自定义字段

            udfBll.UpdateUdfValue(UDF_CATE.PRODUCTS, udf_contact_list, product.id, udf, new UserInfoDto {
                id = user.id, name = user.name
            }, OPER_LOG_OBJ_CATE.PRODUCT);

            return(ERROR_CODE.SUCCESS);
        }