public static Department CreateDepartment(DepartmentNames name) { Department d = null; if (name == null) { return(null); } switch (name) { case DepartmentNames.SERVICE: d = new ServiceDepartment(); break; case DepartmentNames.SALES: d = new SalesDepartment(); break; case DepartmentNames.FINANCE: d = new FinanceDepartment(); break; default: break; } return(d); }
private bool ServiceDepartment_atSaveClick(object source, SaveClickEventArgs e) { try { if (NewRecord) { GetSeqNo(); s_Department = new ServiceDepartment(); } s_Department.LocationID = GlobalFunctions.LoginLocationID; s_Department.LoginUserID = GlobalFunctions.LoginUserID; s_Department.DepartmentCode = txtCode.Text; s_Department.DepartmentName = txtName.Text; if (NewRecord) { db.ServiceDepartments.AddObject(s_Department); } if (!NewRecord) { db.ObjectStateManager.ChangeObjectState(s_Department, System.Data.EntityState.Modified); } db.SaveChanges(); PopulateServiceDepartment(); return(true); } catch (UpdateException updEx) { db.DetachAllEntities(); if (updEx.InnerException.Message.Contains("UC_ServiceDepartmentCode")) { if (FirstSaveClick == true && atMessageBox.Show(MessageKeys.MsgCodeAlreadyExistsDoYouWantToFollowTheSeriesBasedOnPreviousSequence, MessageBoxButtons.YesNo) == DialogResult.No) { txtCode.Focus(); return(false); } FirstSaveClick = false; return(ServiceDepartment_atSaveClick(source, e)); } else if (updEx.InnerException != null) { if (updEx.InnerException.Message.Contains("UC_ServiceDepartmentName")) { atMessageBox.Show(MessageKeys.MsgAnother + MessageKeys.MsgService + " (" + txtName.Text + ") " + MessageKeys.MsgWithSameNameAlreadyExistsPleaseEnterDifferentName); txtName.Focus(); return(false); } } ExceptionManager.Publish(updEx); atMessageBox.Show(updEx, ENOperation.Save); return(false); } catch (Exception ex) { db.DetachAllEntities(); ExceptionManager.Publish(ex); atMessageBox.Show(ex, ENOperation.Save); return(false); } }
public override void ReLoadData(int ID) { db = atContext.CreateContext(); s_Department = db.ServiceDepartments.Where(x => x.id == ID).SingleOrDefault(); if (s_Department != null) { txtCode.Text = s_Department.DepartmentCode; txtName.Text = s_Department.DepartmentName; } }
private void ServiceDepartment_atInitialise() { try { db = atContext.CreateContext(); s_Department = new ServiceDepartment(); PrintButton.Visible = false; ShareButton.Visible = false; MaximizeButton.Visible = false; MinimizeButton.Visible = false; } catch (Exception ex) { ExceptionManager.Publish(ex); atMessageBox.Show(ex, ENOperation.Initialise); } }
private void ServiceDepartment_atNewClick(object source) { try { s_Department = new ServiceDepartment(); db = atContext.CreateContext(); GetSeqNo(); txtCode.Focus(); PopulateServiceDepartment(); } catch (Exception ex) { ExceptionManager.Publish(ex); atMessageBox.Show(ex, ENOperation.AfterInitialise); return; } }