public void SaveAccountType(Data.Models.AccountType accountType) { try { using (Data.Models.ProAccountContext db = new Data.Models.ProAccountContext()) { if (accountType.Id > 0) { var data = db.AccountTypes.FirstOrDefault(w => w.Id == accountType.Id); if (data != null) { data.Type = accountType.Type; db.SaveChanges(); } } else { db.AccountTypes.Add(new Data.Models.AccountType { Type = accountType.Type, }); db.SaveChanges(); } } } catch (SqlException ex) { } }
private void assignDatatoFields(Data.Models.AccountType accountTypedata) { try { TypeId = accountTypedata.Id; txtSearchType.Text = accountTypedata.Type; txtAccountType.Text = accountTypedata.Type; } catch (Exception ex) { MessageBox.Show(ex.Message, Comman.Product_Name, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnTypeSave_Click(object sender, EventArgs e) { try { if (txtAccountType.Text != "") { accountService = new AccountService(); Data.Models.AccountType accountData = new Data.Models.AccountType(); accountData.Id = TypeId; accountData.Type = txtAccountType.Text; accountService.SaveAccountType(accountData); txtAccountType.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message, Comman.Product_Name, MessageBoxButtons.OK, MessageBoxIcon.Error); } }