public ActionResult TableServerSideGetData2(int pageIndex, int pageSize, int SessionStaffID = 0, string filter = "") { var db = new EmployeeBonus_DisciplineDAL(); 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); int Type = 1; // Ky luat var result = db.GetEmployeeBonus_Discipline(baseListParam, out total, SessionStaffID, Type); return(Content(JsonConvert.SerializeObject(new { employees = result, totalCount = total }))); }
public ActionResult GetActionByParentAndType(int ParentID, int Type) { var db = new EmployeeBonus_DisciplineDAL(); var result = db.GetActionByParentAndType(ParentID, Type); return(Content(JsonConvert.SerializeObject(new { result }))); }
public ActionResult GetEditItemById(int id, int idTable) { var db = new EmployeeBonus_DisciplineDAL(); var result = db.GetEmployeeBonus_DisciplineDALById(Global.CurrentUser.RoleId, idTable, id, Global.CurrentLanguage); return(Content(JsonConvert.SerializeObject(new { result }))); }
public ActionResult _DeleteEmployeeBonusDiscipline(int id, int idTable) { var db = new EmployeeBonus_DisciplineDAL(); var result = db.DeleteEmployeeBonusDiscipline(Global.CurrentUser.RoleId, idTable, id, Global.CurrentLanguage); if (result.IsSuccess == true) { result.Message = AppRes.MS_Delete_success; } else { result.Message = AppRes.NotFound; } return(Content(JsonConvert.SerializeObject(new { result }))); }
public ActionResult SaveEmployeeBonusDiscipline(EmployeeBonus_Discipline obj) { var db = new EmployeeBonus_DisciplineDAL(); int staffID = 0; int.TryParse(Session["StaffID"].ToString(), out staffID); obj.CreatedBy = Global.CurrentUser.UserID; obj.ModifiedBy = Global.CurrentUser.UserID; var result = db.SaveEmployeeBonusDiscipline(Global.CurrentUser.RoleId, 1, obj, staffID); if (result.IsSuccess == true && obj.AutoID == 0) { result.Message = AppRes.MSG_INSERT_SUCCESSFUL; } else if (result.IsSuccess == true && obj.AutoID != 0) { result.Message = AppRes.MS_Update_success; } return(Content(JsonConvert.SerializeObject(new { result }))); }
public ActionResult EmployeeBonusDisciplineExportExcel(string filterString, int pageIndex, int pageSize, int Type, int SessionStaffID = 0) { DataTable dt = new DataTable("Grid"); if (Type == 1) { dt.Columns.AddRange(new DataColumn[9] { new DataColumn(AppRes.DisciplineGroup), new DataColumn(AppRes.DisciplinaryContent), new DataColumn(AppRes.DisciplineForm), new DataColumn(AppRes.FineAmount), new DataColumn(AppRes.Currency), new DataColumn(AppRes.DecisionNo), new DataColumn(AppRes.SignDay), new DataColumn(AppRes.EffectiveDate), new DataColumn(AppRes.Note) }); } else { dt.Columns.AddRange(new DataColumn[9] { new DataColumn(AppRes.RewardGroup), new DataColumn(AppRes.RewardContent), new DataColumn(AppRes.RewardForm), new DataColumn(AppRes.RewardMoney), new DataColumn(AppRes.Currency), new DataColumn(AppRes.DecisionNo), new DataColumn(AppRes.SignDay), new DataColumn(AppRes.EffectiveDate), new DataColumn(AppRes.Note) }); } dt.Columns[3].DataType = typeof(double); var db = new EmployeeBonus_DisciplineDAL(); int?total = 0; int staffID = 0; int.TryParse(Session["StaffID"].ToString(), out staffID); 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.ExportExcelEmployeeBonusDiscipline(baseListParam, out total, SessionStaffID, Type); foreach (var item in lstData) { dt.Rows.Add( item.GroupName, item.Content, item.ActionName, item.Amount, item.CurrencyName, item.DecisionNo, item.SignDate, item.ApplyDate, item.Note ); } var wb = new XLWorkbook(); wb.Worksheets.Add(dt); byte[] data = null; using (var stream = new MemoryStream()) { wb.SaveAs(stream); data = stream.ToArray(); } var excelName = ""; switch (Type) { case 0: // khen thưởng excelName = "EmployeeBonus.xlsx"; break; case 1: // kỷ luật excelName = "EmployeeDiscipline.xlsx"; break; } return(File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", excelName)); }
public ActionResult Upload(int type) { 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 Bonus_DisciplineList = new List <EmployeeBonus_Discipline>(); 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 bonus_Discipline = new EmployeeBonus_Discipline(); bonus_Discipline.AutoID = Convert.ToInt32(workSheet.Cells[rowIterator, 1].Value.ToString()); bonus_Discipline.StaffName = workSheet.Cells[rowIterator, 2].Value == null ? null : workSheet.Cells[rowIterator, 2].Value.ToString(); //bonus_Discipline.OrganizationUnit = workSheet.Cells[rowIterator, 2].Value == null ? null : workSheet.Cells[rowIterator, 2].Value.ToString(); bonus_Discipline.GroupName = workSheet.Cells[rowIterator, 3].Value == null ? null : workSheet.Cells[rowIterator, 3].Value.ToString(); bonus_Discipline.Content = workSheet.Cells[rowIterator, 4].Value == null ? null : workSheet.Cells[rowIterator, 4].Value.ToString(); bonus_Discipline.ActionName = workSheet.Cells[rowIterator, 5].Value == null ? null : workSheet.Cells[rowIterator, 5].Value.ToString(); bonus_Discipline.Amount = Convert.ToDouble(workSheet.Cells[rowIterator, 6].Value.ToString()); bonus_Discipline.CurrencyName = workSheet.Cells[rowIterator, 7].Value == null ? null : workSheet.Cells[rowIterator, 7].Value.ToString(); bonus_Discipline.DecisionNo = workSheet.Cells[rowIterator, 8].Value == null ? null : workSheet.Cells[rowIterator, 8].Value.ToString(); bonus_Discipline.SignDate = workSheet.Cells[rowIterator, 9].Value == null?Convert.ToDateTime(null) : new DateTime(1899, 12, 30).AddDays(Double.Parse(workSheet.Cells[rowIterator, 9].Value.ToString()));; bonus_Discipline.ApplyDate = workSheet.Cells[rowIterator, 10].Value == null?Convert.ToDateTime(null) : new DateTime(1899, 12, 30).AddDays(Double.Parse(workSheet.Cells[rowIterator, 10].Value.ToString())); bonus_Discipline.Note = workSheet.Cells[rowIterator, 11].Value == null ? null : workSheet.Cells[rowIterator, 11].Value.ToString(); bonus_Discipline.StaffCode = workSheet.Cells[rowIterator, 12].Value == null ? null : workSheet.Cells[rowIterator, 12].Value.ToString(); if (bonus_Discipline.SignDate == Convert.ToDateTime("01/01/0001 12:00:00 AM")) { bonus_Discipline.SignDate = null; } if (bonus_Discipline.ApplyDate == Convert.ToDateTime("01/01/0001 12:00:00 AM")) { bonus_Discipline.ApplyDate = null; } Bonus_DisciplineList.Add(bonus_Discipline); } } var db = new EmployeeBonus_DisciplineDAL(); var result = db.ImportExcelBonus_Discipline(Bonus_DisciplineList, type); if (result.IsSuccess == true) { result.Message = AppRes.ImportExcelSuccess; } else { result.Message = AppRes.ImportExcelFailed; } return(Content(JsonConvert.SerializeObject(new { result }))); } } return(View("Index")); }