private void fSystemInformation_Load(object sender, EventArgs e) { try { btnPhotoClearCus.Enabled = true; btnEmpPPClear.Enabled = true; btnSuppClear.Enabled = true; using (DLMSEntities db = new DLMSEntities()) { _SystemInformation = (from c in db.SystemInformations where c.SystemInfoID == 1 select c).FirstOrDefault(); if (_SystemInformation != null) { RefreshValue(); } else { _SystemInformation = new BO.SystemInformation(); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
public void ShowDlg(Customer oCustomer, bool IsNew) { _Customer = oCustomer; _IsNew = IsNew; PopulateOutletName(); PopulateCustomerStatus(); DLMSEntities db = new DLMSEntities(); _SystemInformation = (from c in db.SystemInformations where c.SystemInfoID == 1 select c).FirstOrDefault(); RefreshValue(); this.ShowDialog(); }
public void ShowDlg(Employee oEmployee, bool IsNew) { _IsNew = IsNew; DLMSEntities db = new DLMSEntities(); var _SysInfos = db.SystemInformations; _SystemInformation = (from c in db.SystemInformations where c.SystemInfoID == 1 select c).FirstOrDefault(); _Employee = oEmployee; PopulateDesignationCbo(); RefreshValue(); this.ShowDialog(); }
private void btnSave_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you want to save the information?", "Save Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { using (DLMSEntities db = new DLMSEntities()) { if (_SystemInformation.SystemInfoID <= 0) { RefreshObject(); _SystemInformation.SystemInfoID = db.SystemInformations.Count() > 0 ? db.SystemInformations.Max(obj => obj.SystemInfoID) + 1 : 1; db.SystemInformations.Add(_SystemInformation); } else { _SystemInformation = db.SystemInformations.FirstOrDefault(obj => obj.SystemInfoID == _SystemInformation.SystemInfoID); RefreshObject(); } db.SaveChanges(); MessageBox.Show("Data saved successfully.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { if (ex.InnerException == null) { MessageBox.Show(ex.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(ex.InnerException.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }