protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { Models.MUsers mu = new Models.MUsers(); mu.name = txtuserID.Text; mu.password = txtPassword.Text; Classes.CUsers cu = new Classes.CUsers(); int RetVal = cu.Save(mu); if (RetVal < 0) { ShowFailMessage(); } else if (RetVal == 2) { lbluser.Text = "UserName [" + txtuserID.Text + "] Already exists"; } else { ShowSuccessMessage(); } } }
public List <Models.MViewModels.MViewCashAccountBalanceSheet> GetAll(string AccountType) { List <Models.MViewModels.MViewCashAccountBalanceSheet> Get = new List <Models.MViewModels.MViewCashAccountBalanceSheet>(); Models.MViewModels.MViewCashAccountBalanceSheet mvt = new Models.MViewModels.MViewCashAccountBalanceSheet(); List <Models.MCashTransactions> CashTransactions = new List <Models.MCashTransactions>(); List <Models.MCashAccount> CashAccounts = new List <Models.MCashAccount>(); Classes.CCashTransaction cct = new CCashTransaction(); Classes.CCashAccount cca = new CCashAccount(); Classes.CUsers cu = new CUsers(); CashAccounts = cca.GetAll(); CashTransactions = cct.GetAll(); Get.Clear(); switch (AccountType) { case "Personal": { var joined = from ct in CashTransactions join ca in CashAccounts on ct.CashAccountId equals ca.id where ca.AccountType == Common.Constants.CashAccountTypes.Personal.ToString() select ct; foreach (var item in joined) { mvt = new Models.MViewModels.MViewCashAccountBalanceSheet(); string AccountName = cca.GetAccountNameById(item.CashAccountId); string UserName = cu.GetUserNameById(Convert.ToInt32(item.UserId)); mvt.AccountId = AccountName; mvt.Balance = item.Total; mvt.Credit = item.Credit; mvt.Debit = item.Debit; mvt.Description = item.Description; mvt.TransactionBy = UserName; mvt.Date = item.eDate; Get.Add(mvt); } break; } case "Vendor": { var joined = from ct in CashTransactions join ca in CashAccounts on ct.CashAccountId equals ca.id where ca.AccountType == Common.Constants.CashAccountTypes.Vendor.ToString() select ct; foreach (var item in joined) { mvt = new Models.MViewModels.MViewCashAccountBalanceSheet(); string AccountName = cca.GetAccountNameById(item.CashAccountId); string UserName = cu.GetUserNameById(Convert.ToInt32(item.UserId)); mvt.AccountId = AccountName; mvt.Balance = item.Total; mvt.Credit = item.Credit; mvt.Debit = item.Debit; mvt.Description = item.Description; mvt.TransactionBy = UserName; mvt.Date = item.eDate; Get.Add(mvt); } break; } case "Client": { var joined = from ct in CashTransactions join ca in CashAccounts on ct.CashAccountId equals ca.id where ca.AccountType == Common.Constants.CashAccountTypes.Client.ToString() select ct; foreach (var item in joined) { mvt = new Models.MViewModels.MViewCashAccountBalanceSheet(); string AccountName = cca.GetAccountNameById(item.CashAccountId); string UserName = cu.GetUserNameById(Convert.ToInt32(item.UserId)); mvt.AccountId = AccountName; mvt.Balance = item.Total; mvt.Credit = item.Credit; mvt.Debit = item.Debit; mvt.Description = item.Description; mvt.TransactionBy = UserName; mvt.Date = item.eDate; Get.Add(mvt); } break; } default: break; } return(Get); }