コード例 #1
0
ファイル: Fix.cs プロジェクト: dovanduy/Library
        private void fix_Super_Super_Deliveryman_Salesman(BuySellDoc bsd)
        {
            if (bsd.DeliverymanSalesmanId.IsNullOrWhiteSpace())
            {
                return;
            }

            if (bsd.DeliverymanSalesman.IsNull())
            {
                throw new Exception("Deliveryman Salesman is null.");
            }


            if (bsd.DeliverymanSalesman.ParentSalesmanId.IsNullOrWhiteSpace())
            {
                return;
            }

            if (bsd.DeliverymanSalesman.ParentSalesman.IsNull())
            {
                throw new Exception("Deliveryman Salesman Parent is null.");
            }

            if (bsd.DeliverymanSalesman.ParentSalesman.ParentSalesmanId.IsNullOrWhiteSpace())
            {
                return;
            }

            bsd.DeliverymanSalesman.ParentSalesman.ParentSalesman = SalesmanBiz.Find(bsd.DeliverymanSalesman.ParentSalesman.ParentSalesmanId);
            bsd.DeliverymanSalesman.ParentSalesman.ParentSalesman.IsNullThrowException();
        }
コード例 #2
0
ファイル: Fix.cs プロジェクト: dovanduy/Library
 private void fixOwnerSalesman(BuySellDoc buySellDoc)
 {
     //do we want to allow empty orders??
     if (buySellDoc.OwnerSalesmanId.IsNullOrWhiteSpace())
     {
         buySellDoc.OwnerSalesmanId = null;
     }
     else
     {
         buySellDoc.OwnerSalesman = SalesmanBiz.Find(buySellDoc.OwnerSalesmanId);
         buySellDoc.OwnerSalesman.IsNullThrowException("Salesman not found!");
     }
 }
コード例 #3
0
ファイル: BuySellDocBiz.cs プロジェクト: dovanduy/Library
 public BuySellDocBiz(IRepositry <BuySellDoc> entityDal, BuySellItemBiz buySellItemBiz, BizParameters bizParameters, OwnerBiz ownerBiz, CustomerBiz customerBiz, ShopBiz shopBiz, DeliverymanBiz deliverymanBiz, FreightOfferTrxBiz freightOfferTrxBiz, VehicalTypeBiz vehicalTypeBiz, MessageBiz messageBiz, PeopleMessageBiz peopleMessageBiz, SalesmanBiz salesmanBiz, BuySellDocHistoryBiz buySellDocHistoryBiz)
     : base(entityDal, bizParameters)
 {
     _ownerBiz             = ownerBiz;
     _customerBiz          = customerBiz;
     _shopBiz              = shopBiz;
     _buySellBiz           = entityDal as BuySellDocBiz;
     _buySellItemBiz       = buySellItemBiz;
     _freightOfferTrxBiz   = freightOfferTrxBiz;
     _deliverymanBiz       = deliverymanBiz;
     _vehicalTypeBiz       = vehicalTypeBiz;
     _messageBiz           = messageBiz;
     _peopleMessageBiz     = peopleMessageBiz;
     _salesmanBiz          = salesmanBiz;
     _buySellDocHistoryBiz = buySellDocHistoryBiz;
 }
コード例 #4
0
        private void calculate_CustomerSalesmanPenalty(BuySellDoc bsd, PersonPayingPenalty ppp, decimal totalPaymentAmount)
        {
            if (!bsd.CustomerSalesmanId.IsNullOrWhiteSpace())
            {
                ppp.Salesman_Customer.Clear();
                ppp.Salesman_Customer.Person = SalesmanBiz.GetPersonForPlayer(bsd.CustomerSalesmanId);
                ppp.Salesman_Customer.Person.IsNullThrowException();
                ppp.Salesman_Customer.Comment = "Customer Salesman";
                ppp.Salesman_Customer.Percent = bsd.CustomerSalesmanCommission.Percent;

                if (ppp.Salesman_Customer.Percent == 0)
                {
                    return;
                }
                ppp.Salesman_Customer.Amount = Math.Round(totalPaymentAmount * ppp.Salesman_Customer.Percent / 100, 2);
            }
        }
コード例 #5
0
        private void calculate_Super_DeliverySalesman_Penalty(BuySellDoc bsd, PersonPayingPenalty ppp, decimal totalPaymentAmount)
        {
            if (!bsd.DeliverymanId.IsNullOrWhiteSpace())
            {
                if (!bsd.SuperDeliverymanSalesmanId.IsNullOrWhiteSpace())
                {
                    ppp.Super_Salesman_Deliveryman.Clear();
                    ppp.Super_Salesman_Deliveryman.Person = SalesmanBiz.GetPersonForPlayer(bsd.SuperDeliverymanSalesmanId);
                    ppp.Super_Salesman_Deliveryman.IsNullThrowException();
                    ppp.Super_Salesman_Deliveryman.Comment = "Super Deliveryman Salesman";
                    ppp.Super_Salesman_Deliveryman.Percent = bsd.DeliverymanSalesmanCommission.Percent;

                    if (ppp.Super_Salesman_Deliveryman.Percent == 0)
                    {
                        return;
                    }

                    ppp.Super_Salesman_Deliveryman.Amount = Math.Round(ppp.Super_Salesman_Deliveryman.Percent * totalPaymentAmount / 100, 2);
                }
            }
        }
コード例 #6
0
ファイル: Run_Daily_Tasks.cs プロジェクト: dovanduy/Library
        public void MakeSuperSalesmen()
        {
            List <Salesman> normalSalesmen = SalesmanBiz.FindAll().Where(x => x.IsSuperSalesman == false).ToList();

            if (normalSalesmen.IsNullOrEmpty())
            {
                return;
            }

            int     noOfBsdRequiredToBeSuperSalesman = SuperBiz.GetNumberOfBsdToBecomeSuperSalesman();
            decimal superSalesmanCommission          = Salesman.CommissionPct_Owner_Super_Salesman;
            decimal superSuperSalesmanCommission     = Salesman.CommissionPct_Owner_Super_Super_Salesman;
            string  subject = "Congratulations! You are now a Super Salesman!";

            string body = string.Format("CONGRATULATIONS!!! You have satisfied the requirement of {0} delivered orders. You are truely a SUPER SALESMAN. Now, you can hire other salespeople and make your own sales force that will work for you. You will get a commission of {1} for every sale of theirs. Later, when they become SUPER SALESMEN themselves, you will get {2}% from each of their team sales. Remember, when building a team, if you train them properly, they will be more successful, which will end up making YOU more successful. So, take the time to train them. Help them help you. Now, you have effectively multiplied yourself. The question is now... how big a team can you build? Its all upto you.",
                                        noOfBsdRequiredToBeSuperSalesman,
                                        superSalesmanCommission,
                                        superSuperSalesmanCommission);

            foreach (Salesman sm in normalSalesmen)
            {
                int ttlNoBsdForSalesman = BuySellDocBiz.FindAll().Where(x => (x.CustomerSalesmanId == sm.Id ||
                                                                              x.OwnerSalesmanId == sm.Id ||
                                                                              x.DeliverymanSalesmanId == sm.Id) &&
                                                                        x.BuySellDocStateEnum == EnumLibrary.EnumNS.BuySellDocStateENUM.Delivered)
                                          .Count();

                if (ttlNoBsdForSalesman >= noOfBsdRequiredToBeSuperSalesman)
                {
                    sm.IsSuperSalesman = true;
                    SalesmanBiz.Update(sm);

                    createMessageFor(
                        CurrentUserParameter.SystemPersonId,
                        sm.PersonId,
                        subject,
                        body);
                }
            }
        }
コード例 #7
0
ファイル: Fix.cs プロジェクト: dovanduy/Library
        private void fix_Super_Customer_Salesman(BuySellDoc bsd)
        {
            if (bsd.CustomerSalesmanId.IsNullOrWhiteSpace())
            {
                return;
            }

            if (bsd.CustomerSalesman.IsNull())
            {
                throw new Exception("Customer Salesman is null.");
            }


            if (bsd.CustomerSalesman.ParentSalesmanId.IsNullOrWhiteSpace())
            {
                return;
            }

            if (bsd.CustomerSalesman.ParentSalesman.IsNull())
            {
                bsd.CustomerSalesman.ParentSalesman = SalesmanBiz.Find(bsd.CustomerSalesman.ParentSalesmanId);
                bsd.CustomerSalesman.ParentSalesman.IsNullThrowException();
            }
        }
コード例 #8
0
ファイル: BuySellDocBiz.cs プロジェクト: dovanduy/Library
 private void load_Salesmen_SelectList_Into_BuySellDoc(BuySellDoc buySellDoc)
 {
     buySellDoc.SelectListCustomerSalesman    = SalesmanBiz.SelectList();;
     buySellDoc.SelectListOwnerSalesman       = SalesmanBiz.SelectList();;
     buySellDoc.SelectListDeliverymanSalesman = SalesmanBiz.SelectList();;
 }
コード例 #9
0
        IQueryable <BuySellDoc> getByDocumentType_For(string userId, IQueryable <BuySellDoc> iq_allOrders, BuySellDocumentTypeENUM buySellDocumentTypeEnum)
        {
            //userId.IsNullOrWhiteSpaceThrowArgumentException("You are not logged in.");


            switch (buySellDocumentTypeEnum)
            {
            case BuySellDocumentTypeENUM.Sale:
            {
                try
                {
                    //all orders are returned because this is the admin
                    //if (userId.IsNullOrWhiteSpace())
                    //    return iq_allOrders;
                    if (userId.IsNullOrWhiteSpace())
                    {
                        return(BuySellDoc.IQueryable_GetSaleDocs(iq_allOrders, ""));
                    }

                    Owner owner = OwnerBiz.GetPlayerFor(userId);
                    owner.IsNullThrowException("No Owner");
                    return(BuySellDoc.IQueryable_GetSaleDocs(iq_allOrders, owner.Id));
                }
                catch (Exception e)
                {
                    ErrorsGlobal.Add("Problem getting sales.", MethodBase.GetCurrentMethod(), e);
                    throw new Exception(ErrorsGlobal.ToString());
                }
            }

            case BuySellDocumentTypeENUM.Purchase:
            {
                try
                {
                    //all orders are returned because this is the admin
                    //if (userId.IsNullOrWhiteSpace())
                    //    return iq_allOrders;
                    if (userId.IsNullOrWhiteSpace())
                    {
                        return(BuySellDoc.IQueryable_GetPurchaseDocs(iq_allOrders, ""));
                    }

                    Customer customer = CustomerBiz.GetPlayerFor(userId);
                    customer.IsNullThrowException("Customer");
                    return(BuySellDoc.IQueryable_GetPurchaseDocs(iq_allOrders, customer.Id));
                }
                catch (Exception e)
                {
                    ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e);
                    throw new Exception(ErrorsGlobal.ToString());
                }
            }

            case BuySellDocumentTypeENUM.Delivery:
            {
                try
                {
                    //all orders are returned because this is the admin
                    if (userId.IsNullOrWhiteSpace())
                    {
                        return(BuySellDoc.IQueryable_GetDeliveryDocs(iq_allOrders, ""));
                    }


                    Deliveryman deliveryMan = DeliverymanBiz.GetPlayerFor(userId);
                    deliveryMan.IsNullThrowException("deliveryMan");

                    return(BuySellDoc.IQueryable_GetDeliveryDocs(iq_allOrders, deliveryMan.Id));
                }
                catch (Exception e)
                {
                    ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e);
                    throw new Exception(ErrorsGlobal.ToString());
                }
            }

            case BuySellDocumentTypeENUM.Salesman:
            {
                try
                {
                    if (userId.IsNullOrWhiteSpace())
                    {
                        return(BuySellDoc.IQueryable_GetSalesmanDocs(iq_allOrders, ""));
                    }

                    Salesman salesman = SalesmanBiz.GetPlayerFor(userId);
                    salesman.IsNullThrowException("Salesman");

                    return(BuySellDoc.IQueryable_GetSalesmanDocs(iq_allOrders, salesman.Id));
                }
                catch (Exception e)
                {
                    ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e);
                    throw new Exception(ErrorsGlobal.ToString());
                }
            }

            case BuySellDocumentTypeENUM.Unknown:
            default:
                throw new Exception("Unknown document type");
            }
        }