public int Update(Models.MBankAccount model) { Common.Logger l = new Common.Logger(); string ClassName = "CBankAccounts"; try { var query = from o in obj.BankAccounts where Convert.ToString(o.id) == model.id select o; foreach (var item in query) { item.BankId = Convert.ToInt32(model.BankId); item.AccountNumber = model.accountNumber; item.AccountTitle = model.Accounttitle; item.AccountHolderId = model.AccountHolderId; item.BeginDate = model.BeginDate; } //l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] BankId[" + model.BankId + "] AccountNumber[" + model.accountNumber + "] AccountTitle[" + model.Accounttitle + "] AccountHolderId [ " + model.AccountHolderId + "] BeginDate [ " + model.BeginDate + " ] "); obj.SubmitChanges(); // //l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Updated Successfully"); return(1); } catch { //l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString()); return(-1); } }
protected void btnSave_Click(object sender, EventArgs e) { string AccountId = lblAccountTransaction.Text; string AccountNumber = txtAccountNumber.Text; string AccountTitle = txtAccountTitle.Text; string AccountHolderId = txtAccountHolderId.Text; string BankId = txtBankId.Text; Models.MBankAccount mv = new Models.MBankAccount(); mv.id = AccountId; mv.BankId = BankId; mv.accountNumber = AccountNumber; mv.Accounttitle = AccountTitle; mv.AccountHolderId = AccountHolderId; mv.OpeningBalance = txtOpeningBalance.Text; mv.Balance = txtBalance.Text; Classes.CBankOfAccount ccv = new Classes.CBankOfAccount(); if (ccv.Update(mv) < 0) { ShowFailMessage(); } else { ShowSuccessMessage(); BindData(); } }
protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { if (Convert.ToInt32(ddlBankId.SelectedValue) > 0) { string AccountBankId = ddlBankId.SelectedValue; string AccountNumber = txtAccountNumber.Text; string AccountTitle = txtAccountTitle.Text; string AccountHolderId = txtAccountHolderId.Text; string OpeningDate = txtBeginDate.Text; string OpeningBalance = txtOpeningBalance.Text; Models.MBankAccount mv = new Models.MBankAccount(); mv.BankId = AccountBankId; mv.accountNumber = AccountNumber; mv.Accounttitle = AccountTitle; mv.AccountHolderId = AccountHolderId; mv.BeginDate = OpeningDate; mv.OpeningBalance = OpeningBalance; mv.Balance = OpeningBalance; mv.WareHouseId = Session["WareHouse"].ToString(); Classes.CBankOfAccount ccv = new Classes.CBankOfAccount(); if (ccv.Save(mv) < 0) { ShowFailMessage(); } else { Classes.CAccountTransaction cat = new Classes.CAccountTransaction(); Models.MAccountTransaction mat = new Models.MAccountTransaction(); mat.AccountId = ccv.ReturnLastAccountId().ToString(); mat.CurrentTransaction = "0"; mat.Credit = mv.OpeningBalance; mat.Debit = "0"; mat.eDate = DateTime.Now; mat.Total = OpeningBalance; mat.Description = "Opened Account [" + AccountTitle + "] Opening Balance [" + OpeningBalance + "]"; mat.Transactiontype = "Credit"; mat.FiscalYearId = Session["FiscalYear"].ToString(); if (cat.Save(mat) < 0) { ShowFailMessage(); } else { ShowSuccessMessage(); ClearTextBoxes(Page); } } } else { ShowErrorModal("Please Select Bank"); } } }
public int Save(Models.MBankAccount model) { Common.Logger l = new Common.Logger(); // string ClassName = "CBankAccount"; try { DB.BankAccount bs = new DB.BankAccount(); bs.id = Convert.ToInt32(model.id); bs.BankId = Convert.ToInt32(model.BankId); bs.AccountNumber = model.accountNumber; bs.AccountTitle = model.Accounttitle; bs.AccountHolderId = model.AccountHolderId; bs.BeginDate = model.BeginDate; bs.OpeningBalance = model.OpeningBalance; bs.Balance = model.Balance; bs.WareHouseId = Convert.ToInt32(model.WareHouseId); //l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] BankId[" + model.BankId + "] AccountNumber[" + model.accountNumber + "] AccountTitle[" + model.Accounttitle + "] AccountHolderId [ " + model.AccountHolderId + "] BeginDate [ " + model.BeginDate + " ] "); obj.BankAccounts.InsertOnSubmit(bs); obj.SubmitChanges(); Classes.CJournal cj = new CJournal(); DB.Journal j = new DB.Journal(); j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.OwnerEquity); j.amount = Convert.ToSingle(bs.OpeningBalance); j.des = "Opened Bank Account with name[" + bs.AccountTitle + "] "; j.e_date = Convert.ToDateTime(bs.BeginDate); j.type = Common.Constants.Accounts.Type.Credit.ToString(); obj.Journals.InsertOnSubmit(j); obj.SubmitChanges(); j = new DB.Journal(); j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Cash); j.amount = Convert.ToSingle(bs.OpeningBalance); j.des = "Opened Bank Account with name[" + bs.AccountTitle + "] "; j.e_date = Convert.ToDateTime(bs.BeginDate); j.type = Common.Constants.Accounts.Type.Debit.ToString(); obj.Journals.InsertOnSubmit(j); obj.SubmitChanges(); //l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully"); return(1); } catch { //l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString()); return(-1); } }
public List <Models.MBankAccount> GetAllbyid(int id) { List <Models.MBankAccount> model = new List <Models.MBankAccount>(); var query = from o in obj.BankAccounts where Convert.ToString(o.id) == id.ToString() select o; foreach (var item in query) { Models.MBankAccount m = new Models.MBankAccount(); m.id = Convert.ToString(item.id); m.BankId = Convert.ToString(item.BankId); m.accountNumber = item.AccountNumber; m.Accounttitle = item.AccountTitle; m.AccountHolderId = item.AccountHolderId; m.BeginDate = item.BeginDate; model.Add(m); } return(model); }
public List <Models.MBankAccount> GetAll() { List <Models.MBankAccount> model = new List <Models.MBankAccount>(); var query = from o in obj.BankAccounts select o; foreach (var item in query) { Models.MBankAccount m = new Models.MBankAccount(); m.id = Convert.ToString(item.id); m.BankId = Convert.ToString(item.BankId); m.accountNumber = item.AccountNumber; m.Accounttitle = item.AccountTitle; m.AccountHolderId = item.AccountHolderId; m.OpeningBalance = item.OpeningBalance; m.Balance = item.Balance; m.BeginDate = item.BeginDate; m.WareHouseId = Convert.ToString(item.WareHouseId); model.Add(m); } return(model); }