Пример #1
0
        /// <summary>
        /// 排产(主单)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SavePlanForm(string keyValue, Sale_CustomerEntity entity)
        {
            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    if (entity.StatePlanDate != null || entity.EndPlanDate != null)
                    {
                        IRepository db = this.BaseRepository().BeginTrans();
                        entity.PlanMark = 1;
                        entity.Modify(keyValue);
                        db.Update <Sale_CustomerEntity>(entity);


                        //修改销售单排产状态
                        DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                        {
                            PlanMark = 1,
                        };
                        dZ_OrderEntity.Modify(entity.OrderId);//原生产单实体才对
                        db.Update <DZ_OrderEntity>(dZ_OrderEntity);
                        db.Commit();

                        RecordHelp.AddRecord(4, entity.OrderId, "生产排产:" + entity.StatePlanDate.ToString().Replace(" 0:00:00", "") + "至" + entity.EndPlanDate.ToString().Replace(" 0:00:00", ""));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, TrailRecordEntity entity)
        {
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                switch (entity.ObjectSort)
                {
                case 1:             //商机
                    ChanceEntity chanceEntity = new ChanceEntity();
                    chanceEntity.Modify(entity.ObjectId);
                    db.Update <ChanceEntity>(chanceEntity);
                    break;

                case 2:             //客户
                    CustomerEntity customerEntity = new CustomerEntity();
                    customerEntity.Modify(entity.ObjectId);
                    db.Update <CustomerEntity>(customerEntity);
                    break;

                case 3:             //经销商
                    Client_CompanyEntity companyEntity = new Client_CompanyEntity();
                    companyEntity.Modify(entity.ObjectId);
                    db.Update <Client_CompanyEntity>(companyEntity);
                    break;

                case 4:             //订单
                    DZ_OrderEntity orderEntity = new DZ_OrderEntity();
                    orderEntity.Modify(entity.ObjectId);
                    db.Update <DZ_OrderEntity>(orderEntity);
                    break;

                default:
                    break;
                }
                entity.Create();
                db.Insert(entity);

                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Пример #3
0
        /// <summary>
        /// 推单
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="state">状态1推单-1撤单</param>
        /// <param name="orderId">销售单id</param>
        /// <returns></returns>
        public void UpdatePushState(string keyValue, int?state, string orderId)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    Sale_CustomerEntity entity = new Sale_CustomerEntity()
                    {
                        PushMark     = state,
                        PushDate     = DateTime.Now,
                        EndDate      = DateTime.Now.AddDays(30).Date,//最迟交付日期
                        PushUserId   = OperatorProvider.Provider.Current().UserId,
                        PushUserName = OperatorProvider.Provider.Current().UserName
                    };
                    entity.Modify(keyValue);
                    db.Update <Sale_CustomerEntity>(entity);

                    if (!string.IsNullOrEmpty(orderId))
                    {
                        //修改销售单推单状态
                        DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                        {
                            PushMark = state,
                            PushDate = DateTime.Now
                        };
                        dZ_OrderEntity.Modify(orderId);//原生产单实体才对
                        db.Update <DZ_OrderEntity>(dZ_OrderEntity);
                    }
                    db.Commit();

                    RecordHelp.AddRecord(4, orderId, "生产推单");
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Пример #4
0
        /// <summary>
        /// 撤单
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SavePushBackForm(string keyValue, Sale_CustomerEntity entity)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    if (!string.IsNullOrEmpty(entity.PushBackPath))
                    {
                        //修改生产单撤单状态
                        entity.PushMark     = -1;
                        entity.PushDate     = DateTime.Now;
                        entity.PushUserId   = OperatorProvider.Provider.Current().UserId;
                        entity.PushUserName = OperatorProvider.Provider.Current().UserName;

                        //修改销售单撤单状态
                        DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                        {
                            PushMark       = -1,
                            PushDate       = DateTime.Now,
                            PushBackReason = entity.PushBackReason,
                            PushBackPath   = entity.PushBackPath
                        };
                        dZ_OrderEntity.Modify(entity.OrderId);//原生产单实体才对
                        db.Update <DZ_OrderEntity>(dZ_OrderEntity);
                    }
                    entity.Modify(keyValue);
                    db.Update <Sale_CustomerEntity>(entity);
                    db.Commit();
                    RecordHelp.AddRecord(4, entity.OrderId, "生产撤单");
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Пример #5
0
        /// <summary>
        /// 发货物流,同步到销售表
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveLogisticsForm(string keyValue, Buys_OrderEntity entity)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    entity.Modify(keyValue);
                    entity.SendLogisticsMark     = 1;
                    entity.SendLogisticsDate     = DateTime.Now;
                    entity.SendLogisticsUserId   = OperatorProvider.Provider.Current().UserId;
                    entity.SendLogisticsUserName = OperatorProvider.Provider.Current().UserName;
                    db.Update <Buys_OrderEntity>(entity);


                    //同步到销售单-发货通知状态
                    DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                    {
                        SendLogisticsMark     = 1,
                        SendLogisticsDate     = DateTime.Now,
                        SendLogisticsUserId   = OperatorProvider.Provider.Current().UserId,
                        SendLogisticsUserName = OperatorProvider.Provider.Current().UserName
                    };
                    dZ_OrderEntity.Modify(entity.OrderId);
                    db.Update <DZ_OrderEntity>(dZ_OrderEntity);

                    db.Commit();

                    RecordHelp.AddRecord(4, entity.OrderId, "运输信息:" + entity.LogisticsName + " " + entity.LogisticsNO + " " + entity.LogisticsTel + " " + entity.LogisticsCost);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #6
0
        /// <summary>
        /// 安装
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveInstallForm(string keyValue, Buys_OrderEntity entity)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    entity.Modify(keyValue);
                    entity.SendInstallMark     = 1;
                    entity.SendInstallDate     = DateTime.Now;
                    entity.SendInstallUserId   = OperatorProvider.Provider.Current().UserId;
                    entity.SendInstallUserName = OperatorProvider.Provider.Current().UserName;
                    db.Update <Buys_OrderEntity>(entity);

                    //同步到销售单-发货通知状态
                    DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                    {
                        SendInstallMark     = 1,
                        SendInstallDate     = DateTime.Now,
                        SendInstallUserId   = OperatorProvider.Provider.Current().UserId,
                        SendInstallUserName = OperatorProvider.Provider.Current().UserName
                    };
                    dZ_OrderEntity.Modify(entity.OrderId);
                    db.Update <DZ_OrderEntity>(dZ_OrderEntity);

                    db.Commit();
                    RecordHelp.AddRecord(4, entity.OrderId, "安装信息:" + entity.InstallUserName);
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Пример #7
0
        /// <summary>
        /// 下单
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveDownForm(string keyValue, Sale_CustomerEntity entity)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    Sale_CustomerEntity oldEntity      = GetEntity(keyValue);
                    DZ_OrderEntity      dZ_OrderEntity = new DZ_OrderEntity();
                    //原生产单没有下单文件,第一次上传下单文件,则修改下单状态
                    if (entity.DownMark == 1 && oldEntity.DownMark != 1)// && string.IsNullOrEmpty(oldEntity.DownPath)//不管之前有没有上传都修改下单状态
                    {
                        //发微信模板消息---下单之后,给程东彩发消息提醒oA-EC1W1BQZ46Wc8HPCZZUUFbE9M
                        //订单生成通知(8下单提醒)
                        TemplateWxApp.SendTemplateNew("oA-EC1W1BQZ46Wc8HPCZZUUFbE9M", "您好,有新的订单需要推单!", entity.OrderTitle, entity.OrderCode, "请进行审核推单。");
                        RecordHelp.AddRecord(4, entity.OrderId, "生产下单");

                        if (entity.OrderType == 3)
                        {
                            dZ_OrderEntity.PushMark = 1;
                            dZ_OrderEntity.PushDate = DateTime.Now;
                            entity.PushMark         = 1;
                            entity.PushDate         = DateTime.Now;
                            RecordHelp.AddRecord(4, entity.OrderId, "客诉单跳过推单");
                        }
                    }

                    if (entity.DownMark == -1 && oldEntity.DownMark != -1)// && string.IsNullOrEmpty(oldEntity.DownPath)//不管之前有没有上传都修改下单状态
                    {
                        //给刘一珠改刘庆莉发驳回提醒
                        string backMsg = TemplateWxApp.SendTemplateReject("oA-EC1bg4U16c63kR6yj51lA5AiM", "您好,下单人驳回订单!", oldEntity.OrderCode, oldEntity.OrderTitle);
                        RecordHelp.AddRecord(4, entity.OrderId, "生产下单驳回");

                        entity.DownPath = null;//下单驳回,下单附件路径清空
                    }

                    //修改销售单下单状态
                    dZ_OrderEntity.DownMark     = entity.DownMark;
                    dZ_OrderEntity.DownDate     = DateTime.Now;
                    dZ_OrderEntity.DownUserId   = OperatorProvider.Provider.Current().UserId;
                    dZ_OrderEntity.DownUserName = OperatorProvider.Provider.Current().UserName;
                    dZ_OrderEntity.DownPath     = entity.DownPath;
                    dZ_OrderEntity.Modify(entity.OrderId);//原生产单实体才对
                    db.Update <DZ_OrderEntity>(dZ_OrderEntity);


                    //修改生产单下单状态
                    entity.DownDate     = DateTime.Now;
                    entity.DownUserId   = OperatorProvider.Provider.Current().UserId;
                    entity.DownUserName = OperatorProvider.Provider.Current().UserName;
                    entity.Modify(keyValue);
                    db.Update <Sale_CustomerEntity>(entity);
                    db.Commit();
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Пример #8
0
        /// <summary>
        /// 实际发货
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="SendOutImg">主键值</param>
        /// <returns></returns>
        public void UpdateSendState(string keyValue, string SendOutImg)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    Buys_OrderEntity entity = GetEntity(keyValue);
                    entity.Modify(keyValue);
                    entity.SendOutMark     = 1;
                    entity.SendOutImg      = SendOutImg;
                    entity.SendOutDate     = DateTime.Now;
                    entity.SendOutUserId   = OperatorProvider.Provider.Current().UserId;
                    entity.SendOutUserName = OperatorProvider.Provider.Current().UserName;
                    //this.BaseRepository().Update(entity);
                    db.Update <Buys_OrderEntity>(entity);

                    //同步到销售单-发货状态
                    DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                    {
                        SendOutMark     = 1,
                        SendOutImg      = SendOutImg,
                        SendOutDate     = DateTime.Now,
                        SendOutUserId   = entity.SendOutUserId,
                        SendOutUserName = entity.SendOutUserName
                    };
                    dZ_OrderEntity.Modify(entity.OrderId);
                    db.Update <DZ_OrderEntity>(dZ_OrderEntity);

                    //同步到生产表-实际发货状态
                    Sale_CustomerEntity produceEntity = new Sale_CustomerEntity
                    {
                        SendOutMark     = 1,
                        SendOutDate     = DateTime.Now,
                        SendOutUserId   = entity.SendOutUserId,
                        SendOutUserName = entity.SendOutUserName
                    };
                    produceEntity.Modify(entity.ProduceId);
                    db.Update <Sale_CustomerEntity>(produceEntity);


                    //发微信模板消息--给销售人提醒(10实际发货提醒)
                    if (!string.IsNullOrEmpty(entity.SalesmanUserName))
                    {
                        var hsf_CardList = db.IQueryable <Hsf_CardEntity>(t => t.Name.Equals(entity.SalesmanUserName));
                        if (hsf_CardList.Count() != 0)
                        {
                            var hsf_CardEntity = hsf_CardList.First();
                            //订单生成通知,只有关注公众号的业务员才能收到消息(11实际发货提醒)
                            string backMsg = TemplateWxApp.SendTemplateSendOut(hsf_CardEntity.OpenId, "您好,您的订单已经发货!", entity.Code, entity.OrderTitle + ":共" + entity.TotalQty + "包。");
                            if (backMsg != "ok")
                            {
                                //业务员没有关注公众号,报错:微信Post请求发生错误!错误代码:43004,说明:require subscribe hint: [ziWtva03011295]
                                LogHelper.AddLog(entity.SalesmanUserName + "没有关注公众号");//记录日志
                            }
                        }
                    }
                    db.Commit();//此db需要用到查询销售人
                    RecordHelp.AddRecord(4, entity.OrderId, "发货");
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Пример #9
0
        /// <summary>
        /// 发货通知
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveSend(string keyValue, Buys_OrderEntity entity)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    Buys_OrderEntity oldEntity = GetEntity(keyValue);
                    //发货通知时间不为null,老发货通知时间为null
                    if (entity.SendPlanDate != null && entity.SendPlanDate != oldEntity.SendPlanDate)
                    {
                        //发微信模板消息---发货通知之后,给公维才发消息提醒?????
                        //订单生成通知(10发货通知提醒)
                        //公维才
                        TemplateWxApp.SendTemplateSend("oA-EC1Z5tDaD1-ejnQe_l_gJK1Us", "您好,有新的发货通知!", entity.Code, entity.OrderTitle + ",计划发货时间:" + entity.SendPlanDate);
                        //金志花
                        TemplateWxApp.SendTemplateSend("oA-EC1UWi8i4sSkHsWV6BK7CuopA", "您好,有新的发货通知!", entity.Code, entity.OrderTitle + ",计划发货时间:" + entity.SendPlanDate);
                        //牛霞
                        TemplateWxApp.SendTemplateSend("oA-EC1TDoDKimuejhFlBV1U6M5bI", "您好,有新的发货通知!", entity.Code, entity.OrderTitle + ",计划发货时间:" + entity.SendPlanDate);
                        //胡鲁鲁
                        TemplateWxApp.SendTemplateSend("oA-EC1aaKOSNdW2wL8lHSsr3R4Dg", "您好,有新的发货通知!", entity.Code, entity.OrderTitle + ",计划发货时间:" + entity.SendPlanDate);
                    }

                    entity.Modify(keyValue);
                    entity.SendMark     = 1;
                    entity.SendDate     = DateTime.Now;
                    entity.SendUserId   = OperatorProvider.Provider.Current().UserId;
                    entity.SendUserName = OperatorProvider.Provider.Current().UserName;
                    //this.BaseRepository().Update(entity);
                    db.Update <Buys_OrderEntity>(entity);

                    //同步到销售单-发货通知状态
                    DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                    {
                        SendMark     = 1,
                        SendDate     = DateTime.Now,
                        SendPlanDate = entity.SendPlanDate,
                        SendUserId   = entity.SendUserId,
                        SendUserName = entity.SendUserName
                    };
                    dZ_OrderEntity.Modify(entity.OrderId);
                    db.Update <DZ_OrderEntity>(dZ_OrderEntity);

                    //同步到生产表-发货通知状态
                    Sale_CustomerEntity produceEntity = new Sale_CustomerEntity
                    {
                        SendMark     = 1,
                        SendDate     = DateTime.Now,
                        SendPlanDate = entity.SendPlanDate,
                        SendUserId   = entity.SendUserId,
                        SendUserName = entity.SendUserName
                    };
                    produceEntity.Modify(entity.ProduceId);
                    db.Update <Sale_CustomerEntity>(produceEntity);
                    db.Commit();
                    RecordHelp.AddRecord(4, entity.OrderId, "发货通知:" + entity.SendPlanDate.ToString().Replace(" 0:00:00", ""));
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Пример #10
0
        /// <summary>
        /// 分柜体,门板,五金,添加入库之后,判断是否完全入库
        /// </summary>
        /// <param name="itemEntity">实体对象</param>
        /// <returns></returns>
        public void SaveInForm(Buys_OrderItemEntity itemEntity)
        {
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                Buys_OrderItemEntity oldItemEntity = GetDetail(itemEntity.OrderId, itemEntity.SortCode);
                Buys_OrderEntity     buyEntity     = GetEntity(itemEntity.OrderId);

                //先删除再创建
                if (oldItemEntity != null)
                {
                    db.Delete <Buys_OrderItemEntity>(oldItemEntity.OrderEntryId);

                    buyEntity.TotalQty -= oldItemEntity.Qty;//减去老库存
                    if (itemEntity.Qty == 0)
                    {
                        //等于0的情况,直接删掉当前入库记录,当前材料的,入库状态改成null
                        switch (itemEntity.SortCode)
                        {
                        case 1: buyEntity.GuiEnterMark = -1; break;

                        case 2: buyEntity.MenEnterMark = -1; break;

                        case 3: buyEntity.WuEnterMark = -1; break;

                        case 4: buyEntity.WaiEnterMark = -1; break;

                        default:
                            break;
                        }
                    }
                }

                if (itemEntity.Qty > 0)
                {
                    //新增入库单从表,新增要新增,初始化id,用户跳过
                    itemEntity.Create();
                    db.Insert <Buys_OrderItemEntity>(itemEntity);

                    buyEntity.TotalQty += itemEntity.Qty; //加上新库存
                                                          //修改入库状态,分柜体,门板,五金,外协
                    switch (itemEntity.SortCode)
                    {
                    case 1: buyEntity.GuiEnterMark = 1; break;

                    case 2: buyEntity.MenEnterMark = 1; break;

                    case 3: buyEntity.WuEnterMark = 1; break;

                    case 4: buyEntity.WaiEnterMark = 1; break;

                    default:
                        break;
                    }

                    //判断是否完全入库
                    if (buyEntity.GuiEnterMark == 0 || buyEntity.MenEnterMark == 0 || buyEntity.WuEnterMark == 0 || buyEntity.WaiEnterMark == 0)
                    {
                        //还没有完全入库
                        buyEntity.AllEnterMark = 0;
                    }
                    else
                    {
                        //完全入库修改状态
                        buyEntity.AllEnterMark = 1;
                        buyEntity.AllEnterDate = DateTime.Now;

                        //同步到接单表-入库状态
                        DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                        {
                            EnterMark = 1,
                            EnterDate = DateTime.Now
                        };
                        dZ_OrderEntity.Modify(buyEntity.OrderId);
                        db.Update <DZ_OrderEntity>(dZ_OrderEntity);

                        //同步到生产表-入库状态
                        Sale_CustomerEntity produceEntity = new Sale_CustomerEntity
                        {
                            EnterMark = 1,
                            EnterDate = DateTime.Now
                        };
                        produceEntity.Modify(buyEntity.ProduceId);
                        db.Update <Sale_CustomerEntity>(produceEntity);

                        string wk = "";
                        //发微信模板消息--给销售人提醒(完全入库提醒)
                        if (buyEntity.PaymentState == 3 || buyEntity.AfterMark == 0)
                        {
                            //发微信模板消息---完全入库+(收齐尾款或者不需要收取尾款)之后,给胡鲁鲁发消息提醒????给程东彩发全部入库提醒
                            //订单生成通知(9完全入库提醒)
                            TemplateWxApp.SendTemplateAllIn("oA-EC1W1BQZ46Wc8HPCZZUUFbE9M", "您好,有新的订单已经入库!", buyEntity.OrderTitle, "共" + buyEntity.TotalQty + "包,请进行发货通知");
                            if (buyEntity.CompanyId == "0e4ad85a-7bd3-4cba-a390-26ba6d3bf6a2")
                            {
                                //整装部订单全部入库,给戴宝华提醒
                                TemplateWxApp.SendTemplateAllIn("oA-EC1ZrUuePIU9bIapbYnAVe6EU", "您好,有新的订单已经入库!", buyEntity.OrderTitle, "共" + buyEntity.TotalQty + "包,请进行发货通知");
                            }
                        }
                        else
                        {
                            wk = "请确认尾款。";
                        }

                        //发微信模板消息--给销售人提醒(完全入库提醒)
                        if (!string.IsNullOrEmpty(buyEntity.SalesmanUserName))
                        {
                            var hsf_CardList = db.IQueryable <Hsf_CardEntity>(t => t.Name.Equals(buyEntity.SalesmanUserName));
                            if (hsf_CardList.Count() != 0)
                            {
                                var hsf_CardEntity = hsf_CardList.First();
                                //订单生成通知,只有关注公众号的业务员才能收到消息(8完全入库提醒)
                                string backMsg = TemplateWxApp.SendTemplateAllIn(hsf_CardEntity.OpenId, "您好,您的订单已经全部入库!", buyEntity.Code, buyEntity.OrderTitle + ":共" + buyEntity.TotalQty + "包。" + wk);
                                if (backMsg != "ok")
                                {
                                    //业务员没有关注公众号,报错:微信Post请求发生错误!错误代码:43004,说明:require subscribe hint: [ziWtva03011295]
                                    LogHelper.AddLog(buyEntity.SalesmanUserName + "没有关注公众号");//记录日志
                                }
                            }
                        }
                    }
                }

                buyEntity.Modify(buyEntity.Id);
                db.Update <Buys_OrderEntity>(buyEntity);
                db.Commit();

                RecordHelp.AddRecord(4, buyEntity.OrderId, itemEntity.ProductName + "入库" + itemEntity.Qty + "包");
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Пример #11
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <param name="entryList">明细对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, Buys_OrderEntity entity, List <Buys_OrderItemEntity> entryList)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    //主表
                    entity.Modify(keyValue);
                    db.Update(entity);
                    //明细
                    db.Delete <Buys_OrderItemEntity>(t => t.OrderId.Equals(keyValue));

                    foreach (Buys_OrderItemEntity item in entryList)
                    {
                        item.Create();
                        item.OrderId = entity.Id;
                        db.Insert(item);
                    }
                }
                else
                {
                    //新增入库单(自动添加之后,取消使用**************)

                    //主表
                    entity.Create();
                    db.Insert(entity);
                    coderuleService.UseRuleSeed(entity.CreateUserId, "", ((int)CodeRuleEnum.Buy_Order).ToString(), db);//占用单据号
                    //明细
                    foreach (Buys_OrderItemEntity item in entryList)
                    {
                        item.Create();
                        item.OrderId = entity.Id;
                        db.Insert(item);
                    }


                    //同步到接单表-入库状态
                    DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                    {
                        EnterMark = 1,
                        EnterDate = DateTime.Now
                    };
                    dZ_OrderEntity.Modify(entity.OrderId);
                    db.Update <DZ_OrderEntity>(dZ_OrderEntity);
                    //同步到生产表-入库状态
                    Sale_CustomerEntity produceEntity = new Sale_CustomerEntity
                    {
                        EnterMark = 1,
                        EnterDate = DateTime.Now
                    };
                    produceEntity.Modify(entity.ProduceId);
                    db.Update <Sale_CustomerEntity>(produceEntity);
                }
                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Пример #12
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, DZSH_OrderEntity entity)
        {
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    //先拿到老的客诉单
                    DZSH_OrderEntity oldEntity = GetEntity(keyValue);

                    if (entity.NeedSale == 1 && oldEntity.NeedSale == 0)
                    {
                        //改为生产之后,创建销售单
                        CreateDZOrder.SaveDZOrder(db, entity);
                        //发微信模板消息---客诉单接单之后,给审图人提醒--刘琛oA-EC1X6RWfW1_DNJ_VNiA3uhOYg
                        //生成销售单------再通知(审图提醒)
                        TemplateWxApp.SendTemplateNew("oA-EC1X6RWfW1_DNJ_VNiA3uhOYg", "您好,有新的订单需要审图!", entity.OrderTitle, entity.Code, "请进行审图。");
                    }
                    else
                    {
                        //先拿到老的销售单
                        DZ_OrderEntity oldDZEntity = dzService.GetEntity(keyValue);
                        if (oldDZEntity != null)
                        {
                            //如果上传的文件路径变化,判断销售单中的审图状态是否已经审图,已经审图,不能修改文件,需要研发驳回!
                            if (entity.CreatePath != oldEntity.CreatePath && oldDZEntity.CheckTuMark == 1)
                            {
                                throw new Exception("请联系研发审图驳回,再重新上传文件!");
                            }
                            DZ_OrderEntity dzEntity = new DZ_OrderEntity
                            {
                                OrderTitle       = entity.OrderTitle,
                                OrderType        = entity.OrderType,
                                CompanyId        = entity.CompanyId,
                                CompanyName      = entity.CompanyName,
                                CustomerId       = entity.CustomerId,
                                CustomerName     = entity.CustomerName,
                                CustomerTelphone = entity.CustomerTelphone,
                                DesignerUserName = entity.DesignerUserName,
                                DesignerTelphone = entity.DesignerTelphone,
                                Address          = entity.Address,
                                SalesmanUserId   = entity.SalesmanUserId,
                                SalesmanUserName = entity.SalesmanUserName,
                                ShippingType     = entity.ShippingType,
                                Carrier          = entity.Carrier,
                                CreatePath       = entity.CreatePath,
                                Description      = entity.Description,
                            };
                            oldDZEntity.Modify(keyValue);
                            //同步销售单
                            db.Update <DZ_OrderEntity>(dzEntity);//重点关注的是路径是否同步
                        }
                    }

                    entity.Modify(keyValue);
                    //更新
                    db.Update <DZSH_OrderEntity>(entity);
                    db.Commit();
                    RecordHelp.AddRecord(4, entity.Id, "客诉单编辑");
                }
                else
                {
                    entity.Create();
                    db.Insert <DZSH_OrderEntity>(entity);
                    coderuleService.UseRuleSeed(entity.CreateUserId, "", ((int)CodeRuleEnum.DZSH_Order).ToString(), db);//占用单据号
                    if (entity.NeedSale == 1)
                    {
                        //创建新的销售单
                        CreateDZOrder.SaveDZOrder(db, entity);
                        //发微信模板消息---客诉单接单之后,给审图人提醒--刘琛oA-EC1X6RWfW1_DNJ_VNiA3uhOYg
                        //生成销售单------再通知(审图提醒)
                        TemplateWxApp.SendTemplateNew("oA-EC1X6RWfW1_DNJ_VNiA3uhOYg", "您好,有新的订单需要审图!", entity.OrderTitle, entity.Code, "请进行审图。");
                    }

                    db.Commit();
                    RecordHelp.AddRecord(4, entity.Id, "客诉接单");
                    //胡鲁鲁
                    TemplateWxApp.SendTemplateNew("oA-EC1aaKOSNdW2wL8lHSsr3R4Dg", "您好,有新的客诉单!", entity.OrderTitle, entity.Code, "请进行处理。");

                    //邵明钊
                    TemplateWxApp.SendTemplateNew("oA-EC1eudNmGSxra3-c5HJrGGTtk", "您好,有新的客诉单!", entity.OrderTitle, entity.Code, "请进行处理。");
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }