예제 #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
 /// <summary>
 /// 保存VIPApply 的通用方法
 /// </summary>
 /// <param name="apply"></param>
 /// <param name="details"></param>
 /// <returns></returns>
 public int SaveVIPApply(VIPApply apply, List <VIPApplyDetail> details, int OperaterId)
 {
     if (apply.Id == 0)
     {
         return(saveVIPApply(apply, details));
     }
     else
     {
         return(modifyVIPApply(apply, details, OperaterId));
     }
 }
예제 #4
0
        private Order GetOrderInfoByApply(ViewVIPApply apply, int RowNum, Customer customer)
        {
            Order order = new Order();

            order.Address = apply.Address;
            order.ComId   = apply.ComId;
            order.Company = apply.CompanyName;

            VIPApply va = new VIPApply(apply.Id);

            if (va.NewDeptId != 0)
            {
                order.DeptId = va.NewDeptId;
                Dept dept = new Dept(va.NewDeptId);
                order.DeptName = dept.Name;
            }
            else
            {
                order.DeptId   = apply.DeptId;
                order.DeptName = apply.DeptName;
            }
            order.GrossProfit = 0;
            order.MemberId    = apply.MemberId;
            order.Memo        = apply.Memo;
            order.Mobile      = apply.Mobile;
            order.OrderTime   = DateTime.Now;
            order.OrderType   = CommenClass.OrderType.网上订单.ToString();
            order.PayStatus   = CommenClass.PayStatus.未付款.ToString();
            order.PlanDate    = DateTime.Now.AddDays(1);
            order.Point       = 0;
            order.PrintNum    = 0;
            order.RealName    = apply.RealName;
            order.RowNum      = RowNum;
            order.SaveNum     = 0;
            order.SumMoney    = apply.SumMoney;
            order.Telphone    = apply.Telphone;
            order.UpdateTime  = DateTime.Now;
            order.UserId      = 0;
            order.ApplyId     = apply.Id;

            MemberAddress address = new MemberAddress();

            address.Id = apply.MemberAddressId;
            address.Load();
            string city = address.City;

            order.BranchId        = GetVIPBranchId(city, order.ComId);//按默认地址的branchId走,没有的是0。add by luochunhui
            order.TaxRate         = customer.TaxRate;
            order.Invoice_Name    = customer.Invoice_Name;
            order.Invoice_Type    = customer.InvoiceType;
            order.Invoice_Content = customer.Invoice_Content;
            return(order);
        }
예제 #5
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);
        }
예제 #6
0
 /// <summary>
 /// 发送申请单邮件(可审核)
 /// </summary>
 /// <param name="applyId"></param>
 /// <param name="dt">该申请单是被谁审核的 管理员的表 </param>
 /// <returns></returns>
 public bool SendEmail(int applyId, int isPass)
 {
     if (applyId > 0)//申请单添加成功,审核消息发送给对应的管理员
     {
         //1、找到要发邮件的对应的人
         //通过ApplyId找到(新申请单生成)申请人,(审核过一级的)审核了一次的审核人
         VIPApply apply = new VIPApply(applyId);
         if (apply.Status == "待审核")
         {
             int            memberId = apply.OperatorId > 0 ? apply.OperatorId : apply.MemberId;
             VIPApplyOption option   = new VIPApplyOption();
             Member         member   = new Member();
             DataSet        ds       = member.GetDeptComIdByMemberId(memberId);
             option.ComId    = Convert.ToInt32(ds.Tables[0].Rows[0]["ComId"]);
             option.MemberId = memberId;
             option.RoleId   = 2;//成本中心管理员
             option.Code     = Convert.ToString(ds.Tables[0].Rows[0]["Code"]);
             VIPApplyManager vam       = new VIPApplyManager();
             DataSet         dsAdmin   = vam.GetAdmin(option);
             List <int>      memberIds = new List <int>();
             if (dsAdmin.Tables[0].Rows.Count > 0)
             {
                 int SendmemberId = Convert.ToInt32(dsAdmin.Tables[0].Rows[0]["MemberId"]);//上一级成本中心
                 memberIds.Add(SendmemberId);
             }
             //越级是 admin+sys_admin  逐级是admin
             if (isPass == 1)//越级
             {
                 MemberRole role        = new MemberRole();
                 DataSet    dsMemberIds = role.GetSysAdmin(option.ComId);//找到系统管理
                 if (dsMemberIds.Tables[0].Rows.Count > 0)
                 {
                     memberIds.Add(Convert.ToInt32(dsMemberIds.Tables[0].Rows[0]["MemberId"]));
                 }
             }
             if (memberIds.Count > 0)
             {
                 Memberinfocfg configure = new Memberinfocfg();
                 DataSet       dsEmail   = configure.GetIsPassAudit(memberIds);
                 if (dsEmail.Tables[0].Rows.Count > 0)
                 {
                     for (int i = 0; i < dsEmail.Tables[0].Rows.Count; i++)
                     {
                         if (dsEmail.Tables[0].Rows[i]["Type"].ToString() == "实时发送" && Convert.ToInt32(dsEmail.Tables[0].Rows[i]["Value"]) == 1)
                         {
                             string emailss = dsEmail.Tables[0].Rows[i]["Email"].ToString();
                             if (emailss != "")
                             {
                                 int mId = Convert.ToInt32(dsEmail.Tables[0].Rows[i]["MemberId"]);
                                 mailToArray = new string[] { emailss };
                                 mailSubject = "订单审核:您有新订单需要审核 来自 领先办公(Stationery Order: You have one new order need to approve _ from Leading Future)";
                                 mailBody    = EmailBodyStr(applyId, mId);
                                 isbodyHtml  = true;
                                 Send();
                             }
                         }
                     }
                 }
             }
         }
         return(true);
     }
     return(false);
 }
예제 #7
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);
 }