Ejemplo n.º 1
0
        public static void BelowPay(int index, int client_id, decimal insertedMoney, decimal virtualMoney, decimal debtMoney, int state, decimal totalFee, int month)
        {
            using (PSEntity db = new PSEntity())
            {
                CreatePaymentEntry(index, client_id, insertedMoney);

                switch (state)
                {
                case (int)MoneyStates.NODEBTNOVIRTUALMONEY:
                {
                    MessageBox.Show("проходи");
                    CreateDebtEntry(index, client_id, month, Math.Abs(totalFee - insertedMoney));
                    CreateActiveDebtEntry(DebtHandler.getDebtRecord(index, client_id, month).id, client_id);
                    break;
                }

                case (int)MoneyStates.NOVIRTUALMONEY:
                {
                    CreateDebtEntry(index, client_id, month, Math.Abs(totalFee - insertedMoney - debtMoney));

                    var result = db.active_debts.SingleOrDefault(b => b.id == DebtHandler.getDebtRecord(index, client_id, month - 1).id);

                    result.debt_id = DebtHandler.getDebtRecord(index, client_id, month).id;

                    break;
                }

                case (int)MoneyStates.NODEBTMONEY:
                {
                    db.Entry(getVirtualMoneyForService(index, client_id)).State = EntityState.Deleted;

                    CreateDebtEntry(index, client_id, month, Math.Abs(totalFee - insertedMoney - virtualMoney));

                    CreateActiveDebtEntry(DebtHandler.getDebtRecord(index, client_id, month).id, client_id);
                    break;
                }

                case (int)MoneyStates.ALLMONEYPRESENT:
                {
                    db.Entry(getVirtualMoneyForService(index, client_id)).State = EntityState.Deleted;

                    CreateDebtEntry(index, client_id, month, Math.Abs(totalFee - insertedMoney - debtMoney));

                    var result = db.active_debts.SingleOrDefault(b => b.id == DebtHandler.getDebtRecord(index, client_id, month - 1).id);

                    result.debt_id = DebtHandler.getDebtRecord(index, client_id, month).id;

                    break;
                }
                }

                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public static void AbovePay(int index, int client_id, decimal insertedMoney, decimal change, int month, int state)
        {
            using (PSEntity db = new PSEntity())
            {
                CreatePaymentEntry(index, client_id, insertedMoney);

                switch (state)
                {
                case (int)MoneyStates.NODEBTNOVIRTUALMONEY:
                {
                    MessageBox.Show("проходи");
                    CreateVirtualMoneyEntry(index, client_id, Math.Abs(change));
                    break;
                }


                case (int)MoneyStates.NOVIRTUALMONEY:
                {
                    CreateVirtualMoneyEntry(index, client_id, Math.Abs(change));
                    db.Entry(DebtHandler.GetActiveDebt(DebtHandler.getDebtRecord(index, client_id, month - 1).id)).State = EntityState.Deleted;
                    break;
                }

                case (int)MoneyStates.NODEBTMONEY:
                {
                    var result = db.virtual_money.SingleOrDefault(b => b.client_id == client_id && b.service_id == index + 1);
                    result.money = change;
                    db.SaveChanges();
                    break;
                }

                case (int)MoneyStates.ALLMONEYPRESENT:
                {
                    var result = db.virtual_money.SingleOrDefault(b => b.client_id == client_id && b.service_id == index + 1);
                    result.money = change;
                    db.SaveChanges();

                    db.Entry(DebtHandler.GetActiveDebt(DebtHandler.getDebtRecord(index, client_id, month - 1).id)).State = EntityState.Deleted;


                    break;
                }
                }

                db.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public static void OrdinaryPay(int index, int client_id, decimal insertedMoney, int month, int state)
        {
            using (PSEntity db = new PSEntity())
            {
                CreatePaymentEntry(index, client_id, insertedMoney);

                switch (state)
                {
                case (int)MoneyStates.NODEBTNOVIRTUALMONEY:
                {
                    MessageBox.Show("проходи");
                    break;
                }

                case (int)MoneyStates.NOVIRTUALMONEY:
                {
                    db.Entry(DebtHandler.GetActiveDebt(DebtHandler.getDebtRecord(index, client_id, month - 1).id)).State = EntityState.Deleted;

                    break;
                }

                case (int)MoneyStates.NODEBTMONEY:
                {
                    db.Entry(getVirtualMoneyForService(index, client_id)).State = EntityState.Deleted;
                    break;
                }

                case (int)MoneyStates.ALLMONEYPRESENT:
                {
                    db.Entry(getVirtualMoneyForService(index, client_id)).State = EntityState.Deleted;
                    db.Entry(DebtHandler.GetActiveDebt(DebtHandler.getDebtRecord(index, client_id, month - 1).id)).State = EntityState.Deleted;

                    break;
                }
                }

                db.SaveChanges();
            }
        }