コード例 #1
0
ファイル: OrderBonus.cs プロジェクト: thaond/vdms-sym-project
 public static void AddBonus(BonusTransaction bonus, long oid)
 {
     bonus.Id = Guid.NewGuid();
     bonus.SessionId = HttpContext.Current.Session.SessionID;
     if (oid > 0) bonus.OrderId = oid;
     var o = EditingBonuses.FirstOrDefault(b => b.BonusPlanDetailId == bonus.BonusPlanDetailId);
     if (o != null) EditingBonuses.Remove(o);
     EditingBonuses.Add(bonus);
 }
コード例 #2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     long tmp;
     var dc = DCFactory.GetDataContext<BonusDataContext>();
     foreach (GridViewRow r in gv.Rows)
     {
         var usingAmount = long.TryParse(((TextBox)r.Cells[4].FindControl("txtUsingAmount")).Text, out tmp) ? tmp : 0;
         if (usingAmount > 0)
         {
             var newBonus = new BonusTransaction();
             var bonusDetail = dc.BonusPlanDetails.SingleOrDefault(d => d.BonusPlanDetailId == (long.TryParse(r.Cells[0].Text, out tmp) ? tmp : 0));
             newBonus.BonusPlanDetailId = bonusDetail.BonusPlanDetailId;
             newBonus.Amount = long.TryParse(((TextBox)r.Cells[5].FindControl("txtUsingAmount")).Text, out tmp) ? tmp : 0;
             newBonus.OrderId = OrderId;
             newBonus.BonusSourceId = bonusDetail.BonusSourceId;
             newBonus.DealerCode = bonusDetail.DealerCode;
             newBonus.TransactionType = BonusTransactionType.OrderSubstract;
             newBonus.Description = "Bonus used";
             newBonus.BonusSourceName = bonusDetail.BonusSource.BonusSourceName;
             OrderBonus.AddBonus(newBonus, OrderId);
         }
     }
     ClosePopup("updated()");
 }
コード例 #3
0
 private void detach_BonusTransactions(BonusTransaction entity)
 {
     this.SendPropertyChanging("BonusTransactions");
     entity.Dealer = null;
 }
コード例 #4
0
 private void attach_BonusTransactions(BonusTransaction entity)
 {
     this.SendPropertyChanging("BonusTransactions");
     entity.OrderHeader = this;
 }
コード例 #5
0
 private void attach_BonusTransactions(BonusTransaction entity)
 {
     this.SendPropertyChanging("BonusTransactions");
     entity.BonusPlanDetail = this;
 }
コード例 #6
0
ファイル: BonusPlans.cs プロジェクト: thaond/vdms-sym-project
        public static void MakeBonusTrans(BonusDataContext dc, string type, DateTime TransDate, string dCode, string oNum, long Amount, long? BonusPlanDetailId, long? BonusSourceId, string comment)
        {
            var db = dc.Bonus.SingleOrDefault(d => d.DealerCode == dCode);
            if (db == null)
            {
                db = new VDMS.Bonus.Entity.Bonus() { Amount = 0, DealerCode = dCode, };
                DC.Bonus.InsertOnSubmit(db);
            }

            //var oAm = db.Amount;
            db.Amount += Amount;
            if (//oAm >= 0 &&
                db.Amount < 0) throw new Exception("Bonus balance less than zero!");

            // order header via ordernumber
            long? oid = null;
            if (!string.IsNullOrEmpty(oNum))
            {
                var o = OrderDAO.GetOrder(oNum);
                if (o != null) oid = o.OrderHeaderId;
            }

            var th = new BonusTransaction()
            {
                Amount = Amount,
                BonusPlanDetailId = BonusPlanDetailId,
                BonusSourceId = BonusSourceId,
                CreatedDate = DateTime.Now,
                DealerCode = dCode,
                OrderId = oid,
                Description = comment,
                TransactionDate = TransDate.Date,
                UserName = UserHelper.Username,
                TransactionType = type,
            };
            dc.BonusTransactions.InsertOnSubmit(th);
        }
コード例 #7
0
ファイル: OrderBonus.cs プロジェクト: thaond/vdms-sym-project
 public static void DeleteEditingBonus(BonusTransaction bonus)
 {
     var bonusToRemove = EditingBonuses.SingleOrDefault(b => b.Id == bonus.Id);
     if (bonusToRemove.OrderId > 0)
         bonusToRemove.Deleted = true;
     else
         EditingBonuses.RemoveAll(b => b.Id == bonus.Id);
 }