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(); } }
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(); } }