public static int Save(tblAccountsMasterDTO tblAccountsMasterDTO) { using (var dbObject = new BRCTransportDBEntities()) { var tblAccountsMaster = tblAccountsMasterDTO.ToEntity(); if (tblAccountsMasterDTO.AccountId == 0) { dbObject.tblAccountsMasters.Add(tblAccountsMaster); } else { tblAccountsMaster = dbObject.tblAccountsMasters.Find(tblAccountsMasterDTO.AccountId); tblAccountsMaster.AccountName = tblAccountsMasterDTO.AccountName; tblAccountsMaster.AccountType = tblAccountsMasterDTO.AccountType; tblAccountsMaster.AccountNo = tblAccountsMasterDTO.AccountNo; tblAccountsMaster.Addrees = tblAccountsMasterDTO.Addrees; tblAccountsMaster.PhoneNo = tblAccountsMasterDTO.PhoneNo; tblAccountsMaster.OpeningBalance = tblAccountsMasterDTO.OpeningBalance; tblAccountsMaster.OpeningDate = tblAccountsMasterDTO.OpeningDate; tblAccountsMaster.Description = tblAccountsMasterDTO.Description; } dbObject.SaveChanges(); return(tblAccountsMaster.AccountId); } }
private void BtnSave_Click(object sender, EventArgs e) { if (ValidateData()) { tblAccountsMasterDTO tblaccountmasterdto = new tblAccountsMasterDTO(); if (AccountId > 0) { tblaccountmasterdto.AccountId = AccountId; } tblaccountmasterdto.AccountName = textaccountname.Text; if (rbBank.Checked) { tblaccountmasterdto.AccountType = "2"; } else { tblaccountmasterdto.AccountType = "1"; } tblaccountmasterdto.AccountNo = Convert.ToString(textaccountno.Text); tblaccountmasterdto.Addrees = textaddress.Text; tblaccountmasterdto.PhoneNo = textphoneno.Text; tblaccountmasterdto.OpeningBalance = Convert.ToDouble(textopeningbal.Text); tblaccountmasterdto.OpeningDate = accountdate.Value; tblaccountmasterdto.Description = textdescription.Text; var result = AccountsMasterBusinessLogic.Save(tblaccountmasterdto); if (AccountId > 0) { this.Close(); } cleandata(); } }
public ActionResult Save(int id) { tblAccountsMasterDTO tblAccountsMasterDTO; if (id == 0) { tblAccountsMasterDTO = new tblAccountsMasterDTO(); } else { tblAccountsMasterDTO = AccountsMasterBusinessLogic.Get(id); } return(View(tblAccountsMasterDTO)); }
public ActionResult Save(tblAccountsMasterDTO tblAccountsMasterDTO) { if (ModelState.IsValid) { var resultCheckDuplicateAccount = AccountsMasterBusinessLogic.CheckDuplicateAccount(tblAccountsMasterDTO.AccountName, tblAccountsMasterDTO.AccountId); if (resultCheckDuplicateAccount) { ModelState.AddModelError("AccountName", "Account name already exists."); } else { var result = AccountsMasterBusinessLogic.Save(tblAccountsMasterDTO); if (result > 0) { return(RedirectToAction("Index")); } } } return(View(tblAccountsMasterDTO)); }
public static int Save(tblAccountsMasterDTO tblAccountsMasterDTO) { return(AccountsMasterRepository.Save(tblAccountsMasterDTO)); }