public ActionResult TableServerSideGetData(int pageIndex, int pageSize, int SessionStaffID = 0, string filter = "") { var db = new EmployeeRelationshipsDAL(); int?total = 0; var baseListParam = new BaseListParam() { FilterField = filter, OrderByField = "", UserType = Global.CurrentUser.RoleId, UserId = Global.CurrentUser.LoginUserId, DeptId = Global.CurrentUser.OrganizationUnitID, PageIndex = pageIndex, PageSize = pageSize, LanguageCode = Global.CurrentUser.CurrentLanguageID.ToString() }; int staffID = 0; int.TryParse(Session["StaffID"].ToString(), out staffID); var result = db.GetEmployeeRelationships(baseListParam, out total, SessionStaffID); var lstTotal = new TableColumnsTotalModel(); lstTotal.Total1 = "15"; lstTotal.Total2 = "25"; lstTotal.Total3 = "35"; return(Content(JsonConvert.SerializeObject(new { employees = result, totalCount = total, lstTotal = lstTotal }))); }
public ActionResult GetEditItemById(int id, int idTable) { var db = new EmployeeRelationshipsDAL(); var languageID = Global.CurrentLanguage; var result = db.GetEmployeeRelationshipsById(Global.CurrentUser.RoleId, idTable, id, languageID); return(Content(JsonConvert.SerializeObject(new { result }))); }
public ActionResult _DeleteEmployeeRelationships(int id, int idTable) { var db = new EmployeeRelationshipsDAL(); var result = db.DeleteEmployeeRelationships(Global.CurrentUser.RoleId, idTable, id); if (result.IsSuccess == true) { result.Message = AppRes.MS_Delete_success; } else { result.Message = AppRes.NotFound; } return(Content(JsonConvert.SerializeObject(new { result }))); }
public ActionResult TableServerSideGetData2(int pageIndex, int pageSize, string filter = "") { var db = new EmployeeRelationshipsDAL(); int?total = 0; var baseListParam = new BaseListParam() { FilterField = filter, OrderByField = "", UserType = Global.CurrentUser.RoleId, UserId = Global.CurrentUser.LoginUserId, DeptId = Global.CurrentUser.OrganizationUnitID, PageIndex = pageIndex, PageSize = pageSize, LanguageCode = Global.CurrentUser.CurrentLanguageID.ToString() }; int staffID = 0; var result = db.GetEmployeeRelationships(baseListParam, out total, staffID); return(Content(JsonConvert.SerializeObject(new { employees = result, totalCount = total }))); }
public ActionResult SaveEmployeeRelationships(EmployeeRelationships obj) { var db = new EmployeeRelationshipsDAL(); obj.CreatedBy = Global.CurrentUser.UserID; obj.ModifiedBy = Global.CurrentUser.UserID; int staffID = 0; int.TryParse(Session["StaffID"].ToString(), out staffID); var result = db.SaveEmployeeRelationships(Global.CurrentUser.RoleId, 1, obj, staffID); if (result.IsSuccess == true && obj.StaffID == 0) { result.Message = AppRes.MSG_INSERT_SUCCESSFUL; } else if (result.IsSuccess == true && obj.StaffID != 0) { result.Message = AppRes.MS_Update_success; } return(Content(JsonConvert.SerializeObject(new { result }))); }
public ActionResult UploadRelationships() { if (Request != null) { HttpPostedFileBase file = Request.Files["file-0"]; if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName)) { string fileName = file.FileName; string fileContentType = file.ContentType; byte[] fileBytes = new byte[file.ContentLength]; var data = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength)); var relationshipsList = new List <EmployeeRelationships>(); using (var package = new ExcelPackage(file.InputStream)) { var currentSheet = package.Workbook.Worksheets; var workSheet = currentSheet.First(); var noOfCol = workSheet.Dimension.End.Column; var noOfRow = workSheet.Dimension.End.Row; for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++) { var relationships = new EmployeeRelationships(); relationships.AutoID = Convert.ToInt32(workSheet.Cells[rowIterator, 1].Value.ToString()); relationships.StaffName = workSheet.Cells[rowIterator, 3].Value == null ? null : workSheet.Cells[rowIterator, 3].Value.ToString(); relationships.OrganizationUnit = workSheet.Cells[rowIterator, 2].Value == null ? null : workSheet.Cells[rowIterator, 2].Value.ToString(); relationships.Name = workSheet.Cells[rowIterator, 5].Value == null ? null : workSheet.Cells[rowIterator, 5].Value.ToString(); relationships.RelationshipName = workSheet.Cells[rowIterator, 4].Value == null ? null : workSheet.Cells[rowIterator, 4].Value.ToString(); relationships.BirthDay = workSheet.Cells[rowIterator, 6].Value == null?Convert.ToDateTime(null) : Convert.ToDateTime(workSheet.Cells[rowIterator, 6].Value.ToString()); relationships.Phone = workSheet.Cells[rowIterator, 7].Value == null ? null : workSheet.Cells[rowIterator, 7].Value.ToString(); relationships.Deduction = Convert.ToBoolean(workSheet.Cells[rowIterator, 8].Value.ToString()); relationships.DeductionCode = workSheet.Cells[rowIterator, 9].Value == null ? null : workSheet.Cells[rowIterator, 9].Value.ToString(); relationships.DeductionFrom = workSheet.Cells[rowIterator, 10].Value == null?Convert.ToDateTime(null) : Convert.ToDateTime(workSheet.Cells[rowIterator, 10].Value.ToString()); relationships.DeductionTo = workSheet.Cells[rowIterator, 11].Value == null?Convert.ToDateTime(null) : Convert.ToDateTime(workSheet.Cells[rowIterator, 11].Value.ToString()); relationships.StatusName = workSheet.Cells[rowIterator, 12].Value == null ? null : workSheet.Cells[rowIterator, 12].Value.ToString(); relationships.Note = workSheet.Cells[rowIterator, 13].Value == null ? null : workSheet.Cells[rowIterator, 13].Value.ToString(); if (relationships.BirthDay == Convert.ToDateTime("01/01/0001 12:00:00 AM")) { relationships.BirthDay = null; } if (relationships.DeductionFrom == Convert.ToDateTime("01/01/0001 12:00:00 AM")) { relationships.DeductionFrom = null; } if (relationships.DeductionTo == Convert.ToDateTime("01/01/0001 12:00:00 AM")) { relationships.DeductionTo = null; } relationshipsList.Add(relationships); } } var db = new EmployeeRelationshipsDAL(); var result = db.ImportExcelRelationships(relationshipsList); if (result.IsSuccess == true) { result.Message = AppRes.ImportExcelSuccess; } else { result.Message = AppRes.ImportExcelFailed; } return(Content(JsonConvert.SerializeObject(new { result }))); } } return(View("Index")); }
public ActionResult EmployeeRelationshipsExportExcel(string filterString, int pageIndex, int pageSize, int Type) { DataTable dt = new DataTable("Grid"); dt.Columns.AddRange(new DataColumn[13] { new DataColumn(AppRes.AutoID), new DataColumn(AppRes.OrganizationUnit), new DataColumn(AppRes.Staff), new DataColumn(AppRes.RelationShip), new DataColumn(AppRes.FullName), new DataColumn(AppRes.Date_Birth), new DataColumn(AppRes.Mobile), new DataColumn(AppRes.Deduction), new DataColumn(AppRes.DeductionCode), new DataColumn(AppRes.DeductionTimeFrom), new DataColumn(AppRes.DeductionTimeTo), new DataColumn(AppRes.Status), new DataColumn(AppRes.Note) }); dt.Columns[0].DataType = typeof(double); var db = new EmployeeRelationshipsDAL(); int?total = 0; int staffID = 0; var baseListParam = new BaseListParam() { FilterField = filterString, OrderByField = "", PageIndex = pageIndex, PageSize = int.MaxValue, UserType = Global.CurrentUser.RoleId, UserId = Global.CurrentUser.LoginUserId, DeptId = Global.CurrentUser.OrganizationUnitID, LanguageCode = Global.CurrentUser.CurrentLanguageID.ToString() }; var lstData = db.ExportExcelEmployeeRelationship(baseListParam, out total, staffID); foreach (var item in lstData) { dt.Rows.Add( item.AutoID, item.OrganizationUnit, item.StaffName, item.RelationshipName, item.Name, item.BirthDay, item.Phone, item.Deduction, item.DeductionCode, item.DeductionFrom, item.DeductionTo, item.StatusName, item.Note ); } var wb = new XLWorkbook(); wb.Worksheets.Add(dt); byte[] data = null; using (var stream = new MemoryStream()) { wb.SaveAs(stream); data = stream.ToArray(); } return(File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "EmployeeRelationships.xlsx")); }