public shop_expense find_shop_expense_By_AppId(string Appid) { try { shop_expense = db.shop_expenses.SingleOrDefault(a => a.app_id == Appid); return(shop_expense); } catch (Exception) { return(null); } }
public shop_expense find_shop_expense_By_ID(int id) { try { shop_expense = db.shop_expenses.SingleOrDefault(a => a.id == id); return(shop_expense); } catch (Exception) { return(null); } }
public shop_expense delete_shop_expense() { try { shop_expense prev_shop_expense = db.shop_expenses.SingleOrDefault(a => a.id == shop_expense.id); db.shop_expenses.DeleteOnSubmit(prev_shop_expense); return(shop_expense); } catch (Exception) { return(null); } }
public shop_expense alter_shop_expense() { try { shop_expense prev_shop_expense = db.shop_expenses.SingleOrDefault(a => a.id == shop_expense.id); prev_shop_expense.amount = shop_expense.amount; prev_shop_expense.comment = shop_expense.comment; prev_shop_expense.date = shop_expense.date; prev_shop_expense.expense_type = shop_expense.expense_type; prev_shop_expense.islocked = shop_expense.islocked; prev_shop_expense.isverified = shop_expense.isverified; prev_shop_expense.shop = shop_expense.shop; prev_shop_expense.expense_type = shop_expense.expense_type; db.SubmitChanges(); return(shop_expense); } catch (Exception) { return(null); } }
public int VerifyExPenses(List <shop_expense> ShopExpenses, bool verifymode) { int returnValue = 0; try { using (TransactionScope scope = new TransactionScope()) { transaction_category tran = new CRUD.transaction_category_crud().find_transaction_category_By_code((verifymode)?"E":"ER"); foreach (shop_expense shopexp in ShopExpenses) { shop_expense expenses = db.shop_expenses.SingleOrDefault(a => a.id == shopexp.id); if (expenses.isverified != verifymode) { expenses.islocked = verifymode; expenses.isverified = verifymode; shop_balance_sheet mastsheet; shop_balance_sheet sheet = (new CRUD.shop_balance_sheet_crud().getBalanceForShop(shopexp.shop.Value)); if (sheet == null) { mastsheet = new shop_balance_sheet { App_id = Application().app_id, credit_balance = 0, netbalance = 0, online_credit = 0, sales_balance = 0, shop = shopexp.shop.Value }; } else { mastsheet = sheet; } shop_transaction transaction = new shop_transaction { app_id = Application().app_id, amount = shopexp.amount.Value, balance_before = mastsheet.netbalance, balance_after = getbal(mastsheet.netbalance, shopexp.amount, tran), posted_by = shopexp.shop1.login.id, shop = shopexp.shop, trans_category = tran.id, trans_timestamp = DateTime.Now, trans_type = (tran.type == true) ? 1 : 0, details = "Exp For - " + shopexp.comment, }; mastsheet.sales_balance = getbal(mastsheet.sales_balance, transaction.amount, tran); mastsheet.netbalance = getbal(mastsheet.netbalance, transaction.amount, tran); db.shop_transactions.InsertOnSubmit(transaction); if (sheet == null) { db.shop_balance_sheets.InsertOnSubmit(mastsheet); } else { shop_balance_sheet prevbalsheet = db.shop_balance_sheets.SingleOrDefault(a => a.shop == shopexp.shop); prevbalsheet.netbalance = mastsheet.netbalance; prevbalsheet.online_credit = mastsheet.online_credit; prevbalsheet.credit_balance = mastsheet.credit_balance; prevbalsheet.sales_balance = mastsheet.sales_balance; } db.SubmitChanges(); scope.Complete(); returnValue++; } } } return(returnValue); } catch (Exception) { return(0); } }
public shop_expense_crud(shop_expense shop_expense_) { this.shop_expense_ = shop_expense_; }