Пример #1
0
        /// <summary>
        /// 将一条申请单提交到上一级
        /// </summary>
        /// <param name="applyId"></param>
        /// <param name="comId"></param>
        /// <returns></returns>
        private int VIPApplyToHigherLevel(int applyId, int confirmLevel, int operatorId, string memo, int isPass)
        {
            VIPApply apply = new VIPApply();

            apply.Id = applyId;
            if (apply.Load())
            {
                apply.ConfirmLevel = confirmLevel;
                apply.OperatorId   = operatorId; //这里处理添加操作员的ID,相当于登录人的memberId
                apply.Save();
                //审核通过一级时给上一级再发送
                LeadingEmail le = new LeadingEmail();
                le.SendEmail(applyId, isPass);

                //保存申请单审核记录表
                Confirmprocess process = new Confirmprocess();
                process.ApplyId      = applyId;
                process.MemberId     = operatorId;
                process.Memo         = memo;
                process.Status       = apply.Status;
                process.ConfirmLevel = confirmLevel;
                process.Amount       = apply.SumMoney;
                process.UpdateTime   = DateTime.Now;
                process.Save();
                return(apply.Id);
            }
            return(0);
        }
Пример #2
0
        /// <summary>
        /// 将单条申请单转换为订单
        /// </summary>
        /// <param name="ApplyId"></param>
        /// <param name="OperatorId"></param>
        /// <param name="RoleId"></param>
        /// <param name="Memo"></param>
        /// <returns></returns>
        private bool ConvertApplyToOrder(int ApplyId, int OperatorId, int RoleId, string Memo, Customer customer)
        {
            ViewVIPApply View_Apply = new ViewVIPApply(ApplyId);

            if (View_Apply.Status != CommenClass.VIPApplyStatus.待审核.ToString())
            {
                return(false);
            }
            VIPApply  apply = new VIPApply(ApplyId);
            DataTable dt    = apply.ReadDetail().Tables[0];
            Order     order = GetOrderInfoByApply(View_Apply, dt.Rows.Count, customer);

            OrderDetail[] od      = GetOrderDetail(dt);//初始化订单明细数据
            OrderManager  om      = new OrderManager();
            int           orderId = om.AddOrder(order, od);

            if (orderId > 0)
            {
                //保存申请单审核记录表
                Confirmprocess process = new Confirmprocess();
                process.ApplyId    = ApplyId;
                process.MemberId   = OperatorId;
                process.Memo       = apply.Memo;
                process.Status     = CommenClass.VIPApplyStatus.已审核.ToString();
                process.Amount     = apply.SumMoney;
                process.UpdateTime = DateTime.Now;

                apply.Status     = CommenClass.VIPApplyStatus.已审核.ToString();
                apply.OperatorId = OperatorId;
                apply.UpdateTime = process.UpdateTime;
                if (RoleId == 1)//系统管理员审核通过的
                {
                    apply.ConfirmLevel   = 0;
                    process.ConfirmLevel = 0;
                }
                else//成本中心管理员通过的
                {
                    Member m    = new Member(OperatorId);
                    Dept   dept = new Dept(m.DeptId);
                    apply.ConfirmLevel   = dept.Level;//同时修改一下申请单的confirmLevel
                    process.ConfirmLevel = dept.Level;
                }
                if (apply.Save() > 0)//申请单状态更改了
                {
                    //发邮件审核通过的通知
                    LeadingEmail email = new LeadingEmail();
                    email.EmailToPass(ApplyId, apply.MemberId);
                }
                process.Save();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        private int saveVIPApply(VIPApply apply, List <VIPApplyDetail> details)
        {
            int Id = apply.Save();

            if (Id > 0)
            {
                foreach (VIPApplyDetail detail in details)
                {
                    detail.ApplyId = Id;
                    detail.Save();
                }
            }
            return(Id);
        }
Пример #4
0
 private int modifyVIPApply(VIPApply apply, List <VIPApplyDetail> details, int OperaterId)
 {
     if (apply.Save() > 0)
     {
         //记录修改明细
         //循环新表处理 修改数量的商品 和 新增商品
         VIPApplyDetail vad = new VIPApplyDetail();
         vad.ApplyId = apply.Id;
         DataTable dtOld = vad.GetApplyDetailByApplyId().Tables[0];
         for (int i = 0; i < details.Count; i++)
         {
             DataRow[] rows = dtOld.Select(string.Format(" GoodsId={0} ", details[i].GoodsId));
             if (rows.Length == 1)//有这个商品
             {
                 int oldNum = DBTool.GetIntFromRow(rows[0], "Num", 0);
                 if (details[i].Num != oldNum)//数量改变需要修改
                 {
                     vad.Id = DBTool.GetIntFromRow(rows[0], "Id", 0);
                     vad.Load();
                     vad.Num = details[i].Num;
                     if (vad.Save() > 0)
                     {
                         //按专柜中没有组合商品处理
                         //修改明细记录
                         VIPApplyModify vam = new VIPApplyModify();
                         vam.ApplyId    = apply.Id;
                         vam.GoodsId    = vad.GoodsId;
                         vam.OldNum     = oldNum;
                         vam.NewNum     = vad.Num;
                         vam.OperaterId = OperaterId;//记录操作人
                         vam.UpdateTime = DateTime.Now;
                         vam.Save();
                     }
                 }
             }
             else //新增商品
             {
                 VIPApplyDetail svad = new VIPApplyDetail();
                 svad.ApplyId  = apply.Id;
                 svad.GoodsId  = details[i].GoodsId;
                 svad.Num      = details[i].Num;
                 svad.VIPPrice = details[i].VIPPrice;
                 if (svad.Save() > 0)
                 {
                     //修改明细记录
                     VIPApplyModify vam = new VIPApplyModify();
                     vam.ApplyId    = apply.Id;
                     vam.GoodsId    = svad.GoodsId;
                     vam.OldNum     = 0;
                     vam.NewNum     = svad.Num;
                     vam.OperaterId = OperaterId;//记录操作人
                     vam.UpdateTime = DateTime.Now;
                     vam.Save();
                 }
             }
         }
         //循环旧表找到删除的商品 记录明细
         foreach (DataRow row in dtOld.Rows)
         {
             int  goodsId  = DBTool.GetIntFromRow(row, "goodsId", 0);
             int  oldnum   = DBTool.GetIntFromRow(row, "num", 0);
             bool isExsist = false;
             for (int i = 0; i < details.Count; i++)
             {
                 if (details[i].GoodsId == goodsId)
                 {
                     isExsist = true;
                     break;
                 }
             }
             if (isExsist == false)
             {
                 VIPApplyDetail dvad = new VIPApplyDetail();
                 //新申请单中无 此项
                 dvad.Id = DBTool.GetIntFromRow(row, "Id", 0);
                 if (dvad.Delete())//删除申请单明细中的某一商品记录
                 {
                     //记录申请单删除某一商品
                     VIPApplyModify vam = new VIPApplyModify();
                     vam.ApplyId    = apply.Id;
                     vam.GoodsId    = goodsId;
                     vam.OldNum     = oldnum;
                     vam.NewNum     = 0;
                     vam.OperaterId = OperaterId;//记录操作人
                     vam.UpdateTime = DateTime.Now;
                     vam.Save();
                 }
             }
         }
     }
     return(apply.Id);
 }