コード例 #1
0
 public void ucChooseEmployee_AfterClickAcceptButton(object sender, EventArgs e)
 {
     try
     {
         hdfTotalRecord.Text = ucChooseEmployee.SelectedRow.Count.ToString();
         foreach (var item in ucChooseEmployee.SelectedRow)
         {
             // get employee information
             var    hs             = RecordController.GetByEmployeeCode(item.RecordID);
             string RecordId       = hs.Id.ToString();
             string EmployeeCode   = hs.EmployeeCode;
             string FullName       = hs.FullName;
             string DepartmentName = hs.DepartmentName;
             string PositionName   = hs.PositionName;
             // insert record to grid
             RM.RegisterClientScriptBlock("insert" + RecordId,
                                          string.Format("addRecord('{0}', '{1}', '{2}', '{3}');", RecordId, EmployeeCode, FullName,
                                                        DepartmentName));
         }
     }
     catch (Exception ex)
     {
         ExtNet.Msg.Alert("Thông báo từ hệ thống", "Có lỗi xảy ra: " + ex.Message).Show();
     }
 }
コード例 #2
0
 private void ucChooseEmployee_AfterClickAcceptButton(object sender, EventArgs e)
 {
     hdfTotalRecord.Text = ucChooseEmployee.SelectedRow.Count.ToString();
     foreach (var item in ucChooseEmployee.SelectedRow)
     {
         // get employee information
         var hs             = RecordController.GetByEmployeeCode(item.RecordID);
         var recordId       = hs.Id.ToString();
         var employeeCode   = hs.EmployeeCode;
         var fullName       = hs.FullName;
         var departmentName = hs.DepartmentName;
         // insert record to grid
         RM.RegisterClientScriptBlock("insert" + recordId,
                                      string.Format("addRecord('{0}', '{1}', '{2}', '{3}');", recordId, employeeCode, fullName,
                                                    departmentName));
     }
 }
コード例 #3
0
 public void ucChooseEmployee_AfterClickAcceptButton(object sender, EventArgs e)
 {
     try
     {
         hdfTotalRecord.Text = ucChooseEmployee.SelectedRow.Count.ToString();
         foreach (var item in ucChooseEmployee.SelectedRow)
         {
             // get employee information
             var training = RecordController.GetByEmployeeCode(item.RecordID);
             // insert record to grid
             RM.RegisterClientScriptBlock("insert" + training.Id,
                                          string.Format("addRecord('{0}', '{1}', '{2}', '{3}');", training.Id, training.EmployeeCode, training.FullName,
                                                        training.DepartmentName));
         }
     }
     catch (Exception ex)
     {
         Dialog.Alert("Thông báo từ hệ thống", "Có lỗi xảy ra: {0}".FormatWith(ex.Message));
     }
 }
コード例 #4
0
 public void ucChooseEmployee_AfterClickAcceptButton(object sender, EventArgs e)
 {
     try
     {
         hdfTotalRecord.Text = ucChooseEmployee.SelectedRow.Count.ToString();
         foreach (var item in ucChooseEmployee.SelectedRow)
         {
             // get employee information
             var hs = RecordController.GetByEmployeeCode(item.RecordID);
             // insert record to grid
             RM.RegisterClientScriptBlock("insert" + hs.Id,
                                          string.Format("addRecord('{0}', '{1}', '{2}', '{3}');", hs.Id, hs.EmployeeCode, hs.FullName,
                                                        hs.DepartmentName));
         }
     }
     catch (Exception ex)
     {
         Dialog.ShowError("" + ex.Message);
     }
 }
コード例 #5
0
ファイル: DecisionSalary.aspx.cs プロジェクト: war-man/HRM
 void ucChooseEmployee1_AfterClickAcceptButton(object sender, EventArgs e)
 {
     foreach (var item in ucChooseEmployee1.SelectedRow)
     {
         //RecordId, EmployeeCode, FullName, DepartmentName, PositionName, QuantumId, SalaryGrade, SalaryFactor, SalaryBasic,
         //SalaryInsurance, SalaryPayDate, PositionAllowance, OtherAllowance, OutFrame
         // get employee information
         if (!string.IsNullOrEmpty(item.RecordID))
         {
             var    hs             = RecordController.GetByEmployeeCode(item.RecordID);
             string RecordId       = hs.Id.ToString();
             string EmployeeCode   = hs.EmployeeCode;
             string FullName       = hs.FullName;
             string DepartmentName = hs.DepartmentName;
             string PositionName   = hs.PositionName;
             // insert record to grid
             RM.RegisterClientScriptBlock("insert" + RecordId,
                                          string.Format(
                                              "addRecord('{0}', '{1}', '{2}', '{3}', '{4}', '', '', '', '', '', '', '', '', '');",
                                              RecordId, EmployeeCode, FullName, DepartmentName, PositionName));
         }
     }
 }
コード例 #6
0
ファイル: PayrollDetail.aspx.cs プロジェクト: war-man/HRM
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdateImportExcel_Click(object sender, DirectEventArgs e)
        {
            var workbook = new WorkBook();

            // upload file

            if (fileExcel.HasFile)
            {
                var path = UploadFile(fileExcel, Constant.PathTemplate);
                if (path != null)
                {
                    // Read data from excel
                    workbook.readXLSX(Path.Combine(Server.MapPath("~/"), Constant.PathTemplate, path));

                    // Export to datatable
                    var dataTable = workbook.ExportDataTable(0,                    //first row
                                                             0,                    //first col
                                                             workbook.LastRow + 1, //last row
                                                             workbook.LastCol + 1, //last col
                                                             true,                 //first row as header
                                                             false                 //convert to DateTime object if it match date pattern
                                                             );

                    // get config by ID
                    var salaryBoardConfig = SalaryBoardConfigController.GetAll(int.Parse(hdfConfigId.Text), null, null, null,
                                                                               SalaryConfigDataType.DynamicValue, null, null);

                    foreach (DataRow row in dataTable.Rows)
                    {
                        // get employee code
                        var employeeCode = row[EmployeeCode].ToString();
                        if (string.IsNullOrEmpty(employeeCode))
                        {
                            continue;
                        }

                        // get record by employee code
                        var record = RecordController.GetByEmployeeCode(employeeCode);

                        foreach (DataColumn col in dataTable.Columns)
                        {
                            foreach (var item in salaryBoardConfig)
                            {
                                // check column name exists
                                if (item.Display != col.ColumnName)
                                {
                                    continue;
                                }

                                // check empty string
                                var value = Convert.ToString(row[col], CultureInfo.InvariantCulture);
                                if (string.IsNullOrEmpty(value))
                                {
                                    continue;
                                }

                                // check if dynamic column value exists
                                var salaryBoardDynamicColumn = SalaryBoardDynamicColumnController.GetAll(null, record.Id.ToString(), int.Parse(hdfPayrollId.Text), item.ColumnCode, true, null, null);

                                if (salaryBoardDynamicColumn.Count > 0)
                                {
                                    // update dynamic column value
                                    salaryBoardDynamicColumn.First().Value = value;
                                    SalaryBoardDynamicColumnController.Update(salaryBoardDynamicColumn.First());
                                }
                                else
                                {
                                    // create dynamic column value
                                    var salaryBoardConfigColumn = new SalaryBoardDynamicColumnModel()
                                    {
                                        RecordId      = record.Id,
                                        SalaryBoardId = int.Parse(hdfPayrollId.Text),
                                        ColumnCode    = item.ColumnCode,
                                        Value         = value,
                                        Display       = item.Display
                                    };
                                    SalaryBoardDynamicColumnController.Create(salaryBoardConfigColumn);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                Dialog.Alert("Bạn chưa chọn tệp tin đính kèm. Vui lòng chọn.");
                return;
            }
            Dialog.Alert("Cập nhật thành công");
            grpPayrollDetail.Reload();
        }
コード例 #7
0
        /// <summary>
        /// Xử lý cập nhật ảnh hàng loạt với ảnh có định dạng [Mã cán bộ].[JPG/PNG]
        /// -   Lọc mã cán bộ từ tên file
        /// -   Đổi tên ảnh và copy sang thư mục chứa ảnh hồ sơ
        /// -   Cập nhật ảnh cho cán bộ vào cơ sở dữ liệu
        /// -   Xóa ảnh trong thư mục giải nén
        /// </summary>
        /// <param name="files">Tên các file trong thư mục giải nén</param>
        private void UpdateImageByEmployeeCode(string[] files)
        {
            try
            {
                var count        = 0;
                var invalidCount = 0;
                var notSuccsess  = string.Empty;
                // thư mục chứa ảnh hồ sơ
                var rootFolder = Server.MapPath("~/" + Constant.PathImageEmployee);

                foreach (var fName in files)
                {
                    if (fName.ToLower().Contains(".jpg") || fName.ToLower().Contains(".png") ||
                        fName.ToLower().Contains(".gif") || fName.ToLower().Contains(".bmp") || fName.ToLower().Contains(".jpeg"))   // chỉ chấp nhận file ảnh JPG và PNG
                    {
                        var fileName = fName.Substring(fName.LastIndexOf('\\') + 1);
                        // lọc mã cán bộ
                        var employeeCode = fileName.Substring(0, fileName.LastIndexOf('.'));
                        // đổi tên ảnh và chuyển sang ảnh hồ sơ
                        var newName = Guid.NewGuid() + fileName;
                        // get record by employeeCode
                        var recordModel = RecordController.GetByEmployeeCode(employeeCode);
                        if (recordModel != null)
                        {
                            recordModel.ImageUrl = newName;
                        }
                        //update cơ sở dữ liệu
                        var isSuccess = RecordController.Update(recordModel);
                        if (isSuccess != null)
                        {
                            File.Move(fName, rootFolder + newName);
                            count++;
                        }
                        else
                        {
                            notSuccsess += employeeCode + ", ";
                        }
                    }
                    else
                    {
                        invalidCount++;
                    }
                }

                // thông báo
                var notifyMessage = string.Empty;
                if (count > 0)
                {
                    notifyMessage += "Cập nhật ảnh thành công cho " + count + " cán bộ.";
                }
                else
                {
                    notifyMessage += "Không có cán bộ nào được cập nhật ảnh.";
                }
                if (invalidCount > 0)
                {
                    notifyMessage += " Có " + invalidCount + " tệp tin không phải định dạng ảnh cho phép.";
                }
                if (notSuccsess.LastIndexOf(',') != -1)
                {
                    notifyMessage += " Không tìm thấy các cán bộ có mã: " + notSuccsess;
                }
                Dialog.Alert("Thông báo", notifyMessage);
            }
            catch (Exception ex)
            {
                Dialog.Alert("Thông báo", "Có lỗi xảy ra:" + ex.Message);
            }
            finally
            {
                // xóa các thư mục thừa trong thư mục giải nén
                var dInfo = new DirectoryInfo(Server.MapPath("ImagesUpload/"));
                dInfo.Delete(true);
            }
        }
コード例 #8
0
        /// <summary>
        /// Read data from excel file and save to db
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="currentRow"></param>
        private void MainProcess(DataTable dataTable, int currentRow)
        {
            // Finish import file
            if (currentRow >= dataTable.Rows.Count)
            {
                Dialog.Alert("Success");
                gridTimeSheetCode.Reload();
                txtSheetName.Clear();
                txtFromRow.Clear();
                txtToRow.Clear();
                return;
            }

            count++;

            var listRecordId = TimeSheetCodeController.GetAll(null, null, null, null, null, true, null, null, null, null);

            var timeSheetCode = new hr_TimeSheetCode()
            {
                StartTime   = DateTime.Now,
                IsActive    = true,
                CreatedDate = DateTime.Now,
                CreatedBy   = CurrentUser.User.DisplayName,
            };

            foreach (DataColumn col in dataTable.Columns)
            {
                switch (col.ColumnName)
                {
                case nameof(TimeSheetCodeModel.EmployeeCode):
                    var record = RecordController.GetByEmployeeCode(dataTable.Rows[currentRow][col].ToString());
                    if (record != null)
                    {
                        timeSheetCode.RecordId = record.Id;
                    }
                    break;

                default:
                    var reg     = @"\(([^)]*)\)";
                    var propVal = dataTable.Rows[currentRow][col];
                    if (Regex.IsMatch(propVal.ToString(), reg))
                    {
                        propVal = Regex.Match(propVal.ToString(), reg).Groups[1].Value;
                    }
                    //get the property information based on the type
                    var propInfo = timeSheetCode.GetType().GetProperty(col.ColumnName);
                    //find the property type
                    if (propInfo == null)
                    {
                        continue;
                    }
                    if (!propInfo.CanWrite)
                    {
                        continue;
                    }
                    var propType = propInfo.PropertyType;

                    //equivalent to the specified object.
                    if (propType.IsEnum)
                    {
                        propVal = Enum.ToObject(propType, int.Parse(propVal.ToString()));
                    }
                    if (propType.Name == typeof(Nullable <>).Name)
                    {
                        if (Nullable.GetUnderlyingType(propType) == typeof(DateTime))
                        {
                            if (!DateTime.TryParseExact(propVal.ToString(), "dd/MM/yyyy",
                                                        CultureInfo.CurrentCulture, DateTimeStyles.None, out var date))
                            {
                                break;
                            }
                            propVal = Convert.ChangeType(date, typeof(DateTime));
                        }
                        else
                        {
                            propVal = Convert.ChangeType(propVal, Nullable.GetUnderlyingType(propType));
                        }
                    }
                    else
                    {
                        propVal = Convert.ChangeType(propVal, propType);
                    }
                    //Set the value of the property
                    propInfo.SetValue(timeSheetCode, propVal, null);
                    break;
                }
            }

            // Check if RecordId exists in TimeSheetCode table
            if (!string.IsNullOrEmpty(timeSheetCode.Code))
            {
                // create model
                var timeSheetCodeMode = new TimeSheetCodeModel(timeSheetCode);
                if (listRecordId.All(tsc => tsc.RecordId != timeSheetCode.RecordId))
                {
                    TimeSheetCodeController.Create(timeSheetCodeMode);
                    ContinueProcess(count);
                }
                else
                {
                    var timeSheetCodeJson = JSON.Serialize(timeSheetCode);

                    hdfTimeSheetCode.Text = timeSheetCodeJson;

                    // Open Messagebox
                    RM.RegisterClientScriptBlock("confirm",
                                                 "showResult(" + count + ", '" + (string.IsNullOrEmpty(timeSheetCodeMode.EmployeeCode) ? "0" : timeSheetCodeMode.EmployeeCode) +
                                                 "', '" + (string.IsNullOrEmpty(timeSheetCodeMode.FullName) ? "0" : timeSheetCodeMode.FullName) + "');");
                }
            }
        }
コード例 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdateImportExcel_Click(object sender, DirectEventArgs e)
        {
            var workbook = new WorkBook();

            // upload file

            if (fileExcel.HasFile)
            {
                var path = UploadFile(fileExcel, Constant.PathTemplate);
                if (path != null)
                {
                    // Read data from excel
                    workbook.readXLSX(Path.Combine(Server.MapPath("~/"), Constant.PathTemplate, path));

                    // Check validation workbook
                    if (CheckValidation(workbook, out _, out _, txtFromRow, txtToRow, txtSheetName) == false)
                    {
                        return;
                    }

                    // Export to datatable
                    var dataTable = workbook.ExportDataTable(0,                    //first row
                                                             0,                    //first col
                                                             workbook.LastRow + 1, //last row
                                                             workbook.LastCol + 1, //last col
                                                             true,                 //first row as header
                                                             false                 //convert to DateTime object if it match date pattern
                                                             );

                    var argumentModels = ArgumentController.GetAll(null, false, KpiStatus.Active, null, null, null);
                    foreach (DataRow row in dataTable.Rows)
                    {
                        //get employee code
                        var employeeCode = row[EmployeeCode].ToString();
                        if (string.IsNullOrEmpty(employeeCode))
                        {
                            continue;
                        }

                        // get record by employee code
                        var record = RecordController.GetByEmployeeCode(employeeCode);

                        foreach (DataColumn col in dataTable.Columns)
                        {
                            foreach (var argument in argumentModels)
                            {
                                //check column name exists
                                if (argument.Name != col.ColumnName)
                                {
                                    continue;
                                }

                                //check empty string
                                var value = Convert.ToString(row[col], CultureInfo.InvariantCulture);
                                if (string.IsNullOrEmpty(value))
                                {
                                    continue;
                                }

                                //check if value exists
                                var employeeArgument = EmployeeArgumentController.GetUnique(Convert.ToInt32(hdfGroup.Text), record.Id, argument.Id,
                                                                                            Convert.ToInt32(hdfMonth.Text), Convert.ToInt32(hdfYear.Text));
                                if (employeeArgument != null)
                                {
                                    //update value
                                    employeeArgument.Value   = value;
                                    employeeArgument.GroupId = !string.IsNullOrEmpty(hdfGroup.Text)
                                        ? Convert.ToInt32(hdfGroup.Text)
                                        : 0;
                                    employeeArgument.EditedBy   = CurrentUser.User.UserName;
                                    employeeArgument.EditedDate = DateTime.Now;
                                    EmployeeArgumentController.Update(employeeArgument);
                                }
                                else
                                {
                                    var model = new EmployeeArgumentModel()
                                    {
                                        RecordId   = record.Id,
                                        ArgumentId = argument.Id,
                                        GroupId    = !string.IsNullOrEmpty(hdfGroup.Text)
                                            ? Convert.ToInt32(hdfGroup.Text)
                                            : 0,
                                        Month = Convert.ToInt32(hdfMonth.Text),
                                        Year  = Convert.ToInt32(hdfYear.Text),
                                        Value = value
                                    };

                                    EmployeeArgumentController.Create(model);
                                }
                            }
                        }
                    }
                    //reset
                    hdfGroup.Reset();
                    cboGroup.Reset();
                    hdfDepartmentId.Reset();
                    cboDepartment.Reset();
                }
            }
            else
            {
                Dialog.Alert("Bạn chưa chọn tệp tin đính kèm. Vui lòng chọn.");
                return;
            }

            Dialog.Alert("Cập nhật thành công");
            //Reset form excel
            fileExcel.Reset();
            txtSheetName.Reset();
            //reload grid
            gpEmployeeArgument.Reload();
        }