private SettingsModel GetModel() { var model = new SettingsModel(); model.SchemeName = "SimpleWF"; using (var session = WF.Sample.Business.Workflow.WorkflowInit.Provider.Store.OpenSession()) { model.Employees = EmployeeHelper.GetAll(); model.Roles = session.Query <Role>().ToList(); model.StructDivision = session.Query <StructDivision>().ToList(); } return(model); }
public ActionResult Edit(Guid?Id) { DocumentModel model = null; if (Id.HasValue) //用户单击某个文档的编辑界面 { var d = DocumentHelper.Get(Id.Value); if (d != null) { CreateWorkflowIfNotExists(Id.Value); var h = DocumentHelper.GetHistory(Id.Value); model = new DocumentModel() { Id = d.Id, AuthorId = d.AuthorId, AuthorName = d.Employee1.Name, Comment = d.Comment, EmloyeeControlerId = d.EmloyeeControlerId, EmloyeeControlerName = d.EmloyeeControlerId.HasValue ? d.Employee.Name : string.Empty, Name = d.Name, Number = d.Number, StateName = d.State, Sum = d.Sum, Commands = GetCommands(Id.Value), AvailiableStates = GetStates(Id.Value), HistoryModel = new DocumentHistoryModel { Items = h } // 关联文档流转历史记录 }; } } else //新建文档的用户界面 { Guid userId = CurrentUserSettings.GetCurrentUser(); model = new DocumentModel() { AuthorId = userId, AuthorName = EmployeeHelper.GetNameById(userId), StateName = "Draft", Commands = new Dictionary <string, string> { }, AvailiableStates = new Dictionary <string, string>() }; } return(View(model)); }
public bool IsInRole(string role) { if (RoleFeatures == null) { EmployeeHelper employeeHelper = new EmployeeHelper(); RoleFeatures = employeeHelper.GetRoleFeaturesForEmployee(ID); } if (RoleFeatures == null) { return(false); } return(RoleFeatures.SingleOrDefault(o => o.Role.Role_Name.Contains(role)) != null); }
private void InitEmployeeData() { var data = EmployeeHelper.GetEmployees(); foreach (var item in data) { var fullName = $"{item.LastName} {item.FirstName}"; this.EmployeeToFixComboBox.ValueMember = item.Id.ToString(); this.EmployeeToFixComboBox.DisplayMember = fullName; this.EmployeeToFixComboBox.Items.Add(new ComboboxItem() { Text = fullName, Value = item.Id }); } }
public static List <Employees> GetEmployee(string branchCode) { try { return((from empbr in EmployeeHelper.GetEmployeeInBranches(null, branchCode) join emp in EmployeeHelper.GetEmployes() on empbr.EmpCode equals emp.Code where empbr.BranchCode == branchCode select emp).ToList()); } catch (Exception ex) { throw ex; } }
public JsonResult DeleteEmployee(int id) { #region Check Rights bool hasRights = false; hasRights = AdminHelper.CheckUserAction(ScreenEnum.Employee, ActionEnum.Delete); if (!hasRights) { return(Json("You are UnAuthorized to do this action")); } #endregion string isDeleted = EmployeeHelper.DeleteEmp(id); return(Json(isDeleted)); }
public bool IsInFeature(EnumFeatures feature) { if (RoleFeatures == null) { EmployeeHelper employeeHelper = new EmployeeHelper(); RoleFeatures = employeeHelper.GetRoleFeaturesForEmployee(ID); } if (RoleFeatures == null) { return(false); } return(RoleFeatures.FirstOrDefault(o => o.Feature.FeatureName == feature.ToString()) != null); }
public IEnumerable <EmployeeDetails> GetAllEmployees() { try { _logger.LogInformation("GetAllEmployees was called"); return(_ctx.Employees .Include(e => e.Dependents) .Select(e => EmployeeHelper.ConverttoEmployeeDetail(e, _rules.Value)) .ToList()); } catch (Exception ex) { _logger.LogError($"Failed to get all Employee: {ex}"); return(null); } }
// used async call public EmployeeDetails Search(SearchCriteria query) { try { _logger.LogInformation("Search was called"); var result = _ctx.Employees .Include(emp => emp.Dependents) .FirstOrDefault(emp => emp.Id == query.Id); return(result == null ? null : EmployeeHelper.ConverttoEmployeeDetail(result, _rules.Value)); } catch (Exception ex) { _logger.LogError($"Failed to get particular Employee: {ex}"); return(null); } }
// // GET: /Admin/Payslip/ public async Task <ActionResult> Index() { ListModel <Employee> l = null; ISession se = NHibernateHelper.CurrentSession; l = await EmployeeHelper.GetAll(); ViewBag.employmentstatus = se.QueryOver <Employmentstatus>() .OrderBy(x => x.Name).Asc.List(); ViewBag.designation = se.QueryOver <Designation>() .OrderBy(x => x.Title).Asc.List(); ViewBag.dept = se.QueryOver <Department>() .OrderBy(x => x.Name).Asc.List(); return(View(l)); }
public bool IsInFeatureAction(EnumFeatures feature, EnumActions action) { if (RoleFeatures == null) { EmployeeHelper employeeHelper = new EmployeeHelper(); RoleFeatures = employeeHelper.GetRoleFeaturesForEmployee(ID); } if (RoleFeatures == null) { return(false); } RoleFeature rf; switch (action) { case EnumActions.Add: rf = RoleFeatures.FirstOrDefault(o => o.Feature.FeatureName.Contains(feature.ToString()) && o.NewAccessInd == true); return(rf != null); case EnumActions.Edit: rf = RoleFeatures.FirstOrDefault(o => o.Feature.FeatureName.Contains(feature.ToString()) && o.EditAccessInd == true); return(rf != null); case EnumActions.Delete: rf = RoleFeatures.FirstOrDefault(o => o.Feature.FeatureName.Contains(feature.ToString()) && o.DeleteAccessInd == true); return(rf != null); case EnumActions.Save: rf = RoleFeatures.FirstOrDefault(o => o.Feature.FeatureName.Contains(feature.ToString()) && (o.NewAccessInd == true || o.EditAccessInd == true)); return(rf != null); case EnumActions.Search: rf = RoleFeatures.FirstOrDefault(o => o.Feature.FeatureName.Contains(feature.ToString()) && o.ViewAccessInd == true); return(rf != null); case EnumActions.Print: rf = RoleFeatures.FirstOrDefault(o => o.Feature.FeatureName.Contains(feature.ToString()) && o.NewAccessInd == true); return(rf != null); default: return(IsInFeature(feature)); } }
public HttpResponseMessage GetAllEmp() { var data = new EmployeeHelper().Get_Emp(new Employee()); if (data != null && data.Count > 0) { return(Request.CreateResponse(HttpStatusCode.OK, data)); } else { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.InternalServerError) { ReasonPhrase = "Internal Server Error.Please Contact your Administrator." }; return(response); } }
public string GetEmployeesByClient(string c) { List <SelectListItem> result = new List <SelectListItem>(); var empList = EmployeeHelper.GetAllByClient(c); foreach (EmployeeViewModel x in empList.OrderBy(x => x.FullName)) { result.Add(new SelectListItem { Text = x.FullName, Value = x.EmployeeId }); } JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(result)); }
public IActionResult RegisterEmployee([FromBody] Employees employee) { if (employee == null) { return(Ok(new APIResponse { status = APIStatus.FAIL.ToString(), response = $"{nameof(employee)} cannot be null" })); } try { if (EmployeeHelper.GetEmployesByID(employee.Code).Count() > 0) { return(Ok(new APIResponse { status = APIStatus.FAIL.ToString(), response = $"Code {employee.Code} is already exists ,please use different code" })); } var result = EmployeeHelper.Register(employee); APIResponse apiResponse; if (result != null) { apiResponse = new APIResponse() { status = APIStatus.PASS.ToString(), response = result }; } else { apiResponse = new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Registration Failed." }; } return(Ok(apiResponse)); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public ActionResult Record(int?id) { var model = new EmployeeViewModel(); SetDropdownFields(); if (id != null) { model = EmployeeHelper.Get(id.Value); } else { model.Gender = "Male"; model.MaritalStatus = "Single"; model.DateOfBirth = DateHelper.DateTimeNow.AddYears(-18); model.RoleId = UserManager.Instance.GetDefaultRole(); model.EmployeeId = "New Record"; } return(View(model)); }
public IActionResult Download(int year, int month) { var actions = new List <(Action <Employee, Report>, Employee)>(); var report = new Report() { Text = MonthNameResolver.MonthName.GetName(year, month) }; var employess = EmployeeHelper.GetListAllEmployes(_connectConfig.EmployeeConnection); if (employess == null) { return(Json("Error. View in log.")); } foreach (var employee in employess) { employee.BuhCode = _buhService.GetCode(employee.Inn).Result; employee.Salary = employee.Salary(_connectConfig.SalaryService); } var grDepartments = employess.GroupBy(x => x.Department); decimal sum = 0; foreach (var gr in grDepartments) { decimal lSum = 0; report.WriteDepartment(gr.Key, gr.ToArray(), out lSum); sum += lSum; } report.WriteCompanySum(sum); report.Save(); var file = System.IO.File.ReadAllBytes("D:\\report.txt"); var response = File(file, "application/octet-stream", "report.txt"); return(response); }
public ActionResult Edit(Guid?Id) { Document model = null; if (Id.HasValue) { CreateWorkflowIfNotExists(Id.Value); model = DocumentHelper.Get(Id.Value); } else { Guid userId = CurrentUserSettings.GetCurrentUser(); model = new Document() { AuthorId = userId, AuthorName = EmployeeHelper.GetNameById(userId), StateName = "Draft" }; } return(View(model)); }
public IActionResult UpdateEmployee([FromBody] Employees employee) { try { if (employee == null) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $"{nameof(employee)} cannot be null" })); } var result = EmployeeHelper.Update(employee); APIResponse apiResponse; if (result != null) { apiResponse = new APIResponse() { status = APIStatus.PASS.ToString(), response = result }; } else { apiResponse = new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Updation Failed." }; } return(Ok(apiResponse)); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public async Task <ActionResult> List() { string employee = CommonHelper.GetValue(Request["employee"]); string staff_id = CommonHelper.GetValue(Request["staff_id"]); int employment_status = CommonHelper.GetValue <int>(Request["employment_status"], 0); int designation = CommonHelper.GetValue <int>(Request["designation"], 0); int dept = CommonHelper.GetValue <int>(Request["dept"], 0); int pgnum = string.IsNullOrEmpty(Request["pgnum"]) ? 1 : Convert.ToInt32(Request["pgnum"]); int pgsize = string.IsNullOrEmpty(Request["pgsize"]) ? 0 : Convert.ToInt32(Request["pgsize"]); string sortcolumn = string.IsNullOrEmpty(Request["sortcolumn"]) ? EmployeeHelper.DEFAULT_SORT_COLUMN : Request["sortcolumn"]; string sortdir = string.IsNullOrEmpty(Request["sortdir"]) ? EmployeeHelper.DEFAULT_SORT_DIR : Request["sortdir"]; Sort sort = new Sort(sortcolumn, sortdir); Dictionary <string, object> filters = new Dictionary <string, object> { { "employee", employee }, { "staff_id", staff_id }, { "employment_status", employment_status }, { "designation", designation }, { "dept", dept } }; ListModel <Employee> l = null; if (string.IsNullOrEmpty(employee) && string.IsNullOrEmpty(staff_id) && employment_status == 0 && designation == 0 && dept == 0) { l = await EmployeeHelper.GetAll(pgnum, pgsize, sort); } else { l = await EmployeeHelper.GetFilterBy(filters, pgnum, pgsize, sort); } return(View("_list", l)); }
private void btnEditEmployee_Click(object sender, EventArgs e) { if (dataGridEmployee.SelectedRows.Count == 1) { // var Cells = dataGridEmployee.SelectedRows[0].Cells; // foreach(DataGridViewCell cell in Cells ) // { // dataGridEmployee.SelectedRows[0].i // } var EditUserDialog = new DialogBoxes.AddEditEmployeeDialog( listOfEmployees[dataGridEmployee.SelectedRows[0].Index]); var dialogResult = EditUserDialog.ShowDialog(); var employee = EditUserDialog.GetDialogEmployee(dialogResult, listOfEmployees[dataGridEmployee.SelectedRows[0].Index].ID); if (employee == null) { return; } EmployeeHelper.EditEmployee(employee); RefreshTable(); } }
public ActionResult Add(int id = 0) { #region Check Rights bool hasRights; if (id == 0) { hasRights = AdminHelper.CheckUserAction(ScreenEnum.Employee, ActionEnum.Add); } else { hasRights = AdminHelper.CheckUserAction(ScreenEnum.Employee, ActionEnum.Edit); } if (!hasRights) { return(RedirectToAction("UnAuthorized", "Home", new { area = "" })); } #endregion ViewBag.DepartmentList = ListCommonHelper.GetDepartmentList(); var empObj = EmployeeHelper.GetEmployeeVm(id); return(View(empObj)); }
private void btnShow_Click(object sender, EventArgs e) { if (!this.CheckFields()) { return; } this.CleanErrors(); this.UpdateCounters(); Employee employee = new Employee() { JobTitle = EmployeeHelper.GetJobTitle((JobTitleComboOptionsEnum)cmbJobPosition.SelectedValue).Value, Name = txtName.Text, Lastname = txtLastname.Text, Salary1 = double.Parse(txtSalary1.Text, nf), Salary2 = double.Parse(txtSalary2.Text, nf), Salary3 = double.Parse(txtSalary3.Text, nf), }; this.Employees.Add(employee); UpdateSumAve(employee); }
private void Form1_Load(object sender, EventArgs e) { BindingSource source = new BindingSource(EmployeeHelper.GetComboJobTitleOptions(), null); this.cmbJobPosition.DataSource = source; this.cmbJobPosition.ValueMember = "Key"; this.cmbJobPosition.DisplayMember = "Value"; this.nf = new NumberFormatInfo(); this.nf.NumberDecimalSeparator = Constants.Environment.DECIMAL_SEPARATOR; txtPaintersCount.Text = "0"; txtCleaningStuffCount.Text = "0"; txtGenStuffCount.Text = "0"; txtAverage.Text = "0"; txtSum.Text = "0"; this.UpdateCounters(); this.UpdateSumAve(); this.DisableButtons(); }
public IActionResult RegisterEmployeeInBranch([FromBody] EmployeeInBranches employeeInBranch) { if (employeeInBranch == null) { return(Ok(new APIResponse { status = APIStatus.FAIL.ToString(), response = $"{nameof(employeeInBranch)} cannot be null" })); } try { var result = EmployeeHelper.RegisterEmployeeInBranch(employeeInBranch); APIResponse apiResponse; if (result != null) { apiResponse = new APIResponse() { status = APIStatus.PASS.ToString(), response = result }; } else { apiResponse = new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Registration Failed." }; } return(Ok(apiResponse)); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult DeleteEmployee(string code) { if (code == null) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $"{nameof(code)}can not be null" })); } try { var result = EmployeeHelper.Delete(code); APIResponse apiResponse; if (result != null) { apiResponse = new APIResponse() { status = APIStatus.PASS.ToString(), response = result }; } else { apiResponse = new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Deletion Failed." }; } return(Ok(apiResponse)); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
void RefreshTable() { dataGridEmployee.Rows.Clear(); dataGridEmployee.MultiSelect = false; listOfEmployees = EmployeeHelper.GetAllEmployees(); int i = 0; foreach (Employee employee in listOfEmployees) { dataGridEmployee.Rows.Insert( i, i + 1, employee.Name, employee.Surname, employee.BirthDay.Date.ToString("dd-MM-yyyy"), employee.Pesel, employee.Address, employee.HireFrom.Date.ToString("dd-MM-yyyy"), employee.HireExp.HasValue ? employee.HireExp.Value.Date.ToString("dd-MM-yyyy") : "Nie dotyczy", employee.Position); i++; } }
private void btnDeleteEmployee_Click(object sender, EventArgs e) { if (dataGridEmployee.SelectedRows.Count == 1) { // var Cells = dataGridEmployee.SelectedRows[0].Cells; // foreach(DataGridViewCell cell in Cells ) // {listOfEmployees[dataGridEmployee.SelectedRows[0].Index] // dataGridEmployee.SelectedRows[0].i // } var employee = listOfEmployees[dataGridEmployee.SelectedRows[0].Index]; if (employee == null) { return; } var dialogResult = MessageBox.Show("Potwierdź usunięcie pracownika: " + Environment.NewLine + Environment.NewLine + employee.Name + " " + employee.Surname + Environment.NewLine + "Zmiany te sa NIEODWRACALNE", "Usuwanie pracownika z bazy danych", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); if (dialogResult == DialogResult.OK) { EmployeeHelper.DeleteEmployee(employee); } RefreshTable(); } }
public ActionResult MyProfile(EmployeeViewModel model, HttpPostedFileBase file) { EmployeeViewModel updModel = model; ViewBag.IsSuccess = false; if (ModelState.IsValid) { SGS.Data.EntityFrameworks.User employee = UserManager.Instance.Get(model.UserId); employee.MaritalStatus = model.MaritalStatus; employee.PresentAddress = model.PresentAddress; employee.ProvincialAddress = model.ProvincialAddress; employee.LandlineNo = model.LandLine; employee.MobileNo = model.MobileNo; employee.Email = model.Email; employee.Ref_Name = model.ReferenceName; employee.Ref_Relationship = model.ReferenceRelationship; employee.Ref_Address = model.ReferenceAddress; employee.Ref_ContactNo = model.ReferenceContactNo; employee.TaxIdNo = model.TaxIdNo; employee.SSSNo = model.SSSNo; employee.HDMFNo = model.HDMFNo; employee.PhilHealthNo = model.PhilHealthNo; employee.ModifiedBy = UserHelper.CurrentUser.EmployeeId; if (file != null) { string filename = "p_" + Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); string pic = System.IO.Path.GetFileName(filename); string path = System.IO.Path.Combine( Server.MapPath(ConfigurationManager.AppSettings["UploadPath"].ToString()), pic); file.SaveAs(path); using (MemoryStream ms = new MemoryStream()) { file.InputStream.CopyTo(ms); byte[] array = ms.GetBuffer(); } employee.Picture = filename; } try { updModel = EmployeeHelper.Get(UserManager.Instance.SaveUser(employee)); ViewBag.Success = true; } catch (Exception ex) { ViewBag.SysError = ex.Message; } } else { ViewBag.Error = true; } return(View(updModel)); }
public ActionResult MyProfile() { return(View(EmployeeHelper.Get(UserHelper.CurrentUser.UserId))); }
/// <summary> /// Fills table Employees with fake test data. /// </summary> /// <param name="aConfig">The test data generator config</param> /// <returns></returns> public void AddRandomEmployees(RandomEmployeeGenaratorConfiguration aConfig) { if (aConfig.EmployeeCount <= 0) { aConfig.EmployeeCount = RANDOM_EMPLOYEE_COUNT_DEFAULT; } if (aConfig.ManagerCount <= 0) { aConfig.ManagerCount = RANDOM_MANAGER_COUNT_DEFAULT; } if (aConfig.SalesCount <= 0) { aConfig.SalesCount = RANDOM_SALES_COUNT_DEFAULT; } long aMinDateTicks = CompanyDateOfEstablishment.Ticks; long aMaxDateTicks = DateTime.Now.Ticks; if (aMinDateTicks <= 0L) { aMinDateTicks = MINIMAL_DATE_TICKS; } var aSalaryPlans = EmployeeListDB.SalaryPlans; bool aRes = aSalaryPlans.Any(v => v.EmployeeType == SalaryPlan.EEmployeeType.Employee) && aSalaryPlans.Any(v => v.EmployeeType == SalaryPlan.EEmployeeType.Manager) && aSalaryPlans.Any(v => v.EmployeeType == SalaryPlan.EEmployeeType.Sales); if (aRes) { Random aRandom = new Random(); var aManagers = new Employee[aConfig.ManagerCount]; var aSalaryPlanId = aSalaryPlans.First(v => v.EmployeeType == SalaryPlan.EEmployeeType.Manager).Id; for (int i = 0; i < aConfig.ManagerCount; i++) { var aEmployee = new Employee { LastName = StringHelper.GenerateRandomString(aRandom, RANDOM_MAX_NAME_LENGTH), FirstName = StringHelper.GenerateRandomString(aRandom, RANDOM_MAX_NAME_LENGTH), MiddleName = StringHelper.GenerateRandomString(aRandom, RANDOM_MAX_NAME_LENGTH), EmploymentDate = (new DateTime(DateTimeHelper.GenerateRandomLong(aRandom, aMinDateTicks, aMaxDateTicks))).Date, SalaryPlanId = aSalaryPlanId }; aManagers[i] = aEmployee; } var aSalesmen = new Employee[aConfig.SalesCount]; aSalaryPlanId = aSalaryPlans.First(v => v.EmployeeType == SalaryPlan.EEmployeeType.Sales).Id; for (int i = 0; i < aConfig.SalesCount; i++) { Employee aManager = null; if ((i > 1) && (aRandom.Next(2) == 0)) { aManager = (aRandom.Next(2) == 0) ? aManagers[aRandom.Next(aManagers.Length)] : aSalesmen[aRandom.Next(i)]; } var aEmployee = new Employee { LastName = StringHelper.GenerateRandomString(aRandom, RANDOM_MAX_NAME_LENGTH), FirstName = StringHelper.GenerateRandomString(aRandom, RANDOM_MAX_NAME_LENGTH), MiddleName = StringHelper.GenerateRandomString(aRandom, RANDOM_MAX_NAME_LENGTH), EmploymentDate = (new DateTime(DateTimeHelper.GenerateRandomLong(aRandom, aMinDateTicks, aMaxDateTicks))).Date, SalaryPlanId = aSalaryPlanId, Manager = aManager }; aSalesmen[i] = aEmployee; } var aEmployees = new Employee[aConfig.EmployeeCount]; aSalaryPlanId = aSalaryPlans.First(v => v.EmployeeType == SalaryPlan.EEmployeeType.Employee).Id; for (int i = 0; i < aConfig.EmployeeCount; i++) { Employee aManager = null; if (aRandom.Next(2) == 0) { aManager = (aRandom.Next(2) == 0) ? aManagers[aRandom.Next(aManagers.Length)] : aSalesmen[aRandom.Next(aSalesmen.Length)]; } var aEmployee = new Employee { LastName = StringHelper.GenerateRandomString(aRandom, RANDOM_MAX_NAME_LENGTH), FirstName = StringHelper.GenerateRandomString(aRandom, RANDOM_MAX_NAME_LENGTH), MiddleName = StringHelper.GenerateRandomString(aRandom, RANDOM_MAX_NAME_LENGTH), EmploymentDate = (new DateTime(DateTimeHelper.GenerateRandomLong(aRandom, aMinDateTicks, aMaxDateTicks))).Date, SalaryPlanId = aSalaryPlanId, Manager = aManager }; aEmployees[i] = aEmployee; } for (int i = 0; i < aManagers.Length; i++) { Employee aManager = null; if (aRandom.Next(2) == 0) { aManager = (aRandom.Next(2) == 0) ? aManagers[aRandom.Next(aManagers.Length)] : aSalesmen[aRandom.Next(aSalesmen.Length)]; if (!EmployeeHelper.IsSubordinate(aManagers[i], aManager)) { aManagers[i].Manager = aManager; } } EmployeeListDB.Employees.Add(aManagers[i]); } EmployeeListDB.Employees.AddRange(aSalesmen); EmployeeListDB.Employees.AddRange(aEmployees); EmployeeListDB.SaveChanges(); } else { throw new Exception("Database contains 0 SalaryPlans."); } }