/// <summary> /// Sinh mã cán bộ dựa vào cấu hình hệ thống: /// - Tiền tố của mã cán bộ /// - Số lượng chữ số theo sau tiền tố /// </summary> /// <returns>Mã cán bộ mới được sinh ra</returns> private string GenerateEmployeeCode() { var departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); var prefix = SystemConfigController.GetValueByNameFollowDepartment(SystemConfigParameter.PREFIX, departments); var numberCharacter = SystemConfigController.GetValueByNameFollowDepartment(SystemConfigParameter.NUMBER_OF_CHARACTER, departments); if (string.IsNullOrEmpty(prefix)) { prefix = "CB"; } var number = string.IsNullOrEmpty(numberCharacter) ? 5 : int.Parse(numberCharacter); var record = RecordController.GetByEmployeeCodeGenerate(prefix, number); var oldMaCb = _generateEmployeeConst; if (record != null && !string.IsNullOrEmpty(record.EmployeeCode)) { oldMaCb = record.EmployeeCode; } var oldNumber = long.Parse("" + oldMaCb.Substring(prefix.Length)); oldNumber++; var newMaCb = _generateEmployeeConst + oldNumber; newMaCb = prefix + newMaCb.Substring(newMaCb.Length - number); return(newMaCb); }
/// <summary> /// Ẩn cột /// </summary> private void HideColumn() { try { var departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); var list = SystemConfigController.GetAllByNameAndDepartment(NameCondition, departments); var columnList = new List <string>(); foreach (var item in list) { if (string.IsNullOrEmpty(item.Value) || (!string.IsNullOrEmpty(item.Value) && bool.Parse(item.Value))) { columnList.Add(item.Name); } } foreach (var item in gridDecisionSalaryEnterprise.ColumnModel.Columns) { if (columnList.Contains(item.ColumnID)) { item.Hidden = true; } } } catch (Exception ex) { X.Msg.Alert("Thông báo từ hệ thống", "Có lỗi xảy ra: " + ex.Message).Show(); } }
private void loadData() { tsbSave.Enabled = false; tsbCancel.Enabled = false; tsbEdit.Enabled = false; CtrlUtil.EnabledControl(false, txtChrData); shtView.ActiveSkin = Common.ACTIVE_SKIN; try { SystemConfigController ctlsys = new SystemConfigController(); SystemConfigurationUIDM model = ctlsys.LoadSysConfig(); //List<SysConfigDTO> dto = ctlsys.LoadSysConfig(); //m_dtAllData = DTOUtility.ConvertListToDataTable(dto); //DataTable dtView = m_dtAllData.Clone(); //foreach (DataRow dr in m_dtAllData.Rows) //{ // dtView.ImportRow(dr); //} fpView.DataSource = model.DATA_VIEW; CtrlUtil.MappingDataFieldWithEnum(shtView, typeof(eColumns)); for (int i = 0; i < shtView.Rows.Count; i++) { if (Convert.ToInt32(shtView.Cells[i, (int)eColumns.EDIT_FLAG].Value) == 1) { shtView.Cells[i, (int)eColumns.EDIT_FLAG].Value = true; } else { shtView.Cells[i, (int)eColumns.EDIT_FLAG].Value = false; } } //if ((shtView.Rows.Count > 0)&& (Convert.ToBoolean(shtView.Cells[0, (int)eColumns.EDIT_FLAG].Value)==true)) // { // txtSysGroupId.Text = Convert.ToString(shtView.Cells[shtView.ActiveRowIndex, (int)eColumns.SYS_GROUP_ID].Value); // txtSysKey.Text = Convert.ToString(shtView.Cells[shtView.ActiveRowIndex, (int)eColumns.SYS_KEY].Value); // txtChrData.Text = Convert.ToString(shtView.Cells[shtView.ActiveRowIndex, (int)eColumns.CHAR_DATA].Value); // tsbEdit.Enabled = true; // } if (shtView.RowCount > 0) { shtView.ActiveRowIndex = 0; shtView.AddSelection(0, 0, 1, 1); shtView.SetActiveCell(0, 0); fpView.ShowActiveCell(VerticalPosition.Top, HorizontalPosition.Left); fpView_SelectionChanged(null, null); } } catch (Exception ex) { MessageDialog.ShowBusiness(this, ex.Message); } }
protected void btnCapNhatCauHinh_Click(object sender, DirectEventArgs e) { try { //SystemController controller = new SystemController(); var controller = new SystemConfigController(); var departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); // department var arrDepartment = departments.Split(new[] { ',' }, StringSplitOptions.None); for (var i = 0; i < arrDepartment.Length; i++) { arrDepartment[i] = "{0}".FormatWith(arrDepartment[i]); } controller.CreateOrSave(SystemConfigParameter.QDL_LUONGCUNG, chkLuongCung.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_HESOLUONG, chkHeSoLuong.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_PHANTRAMHL, chkPhuCapKhac.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_VUOTKHUNG, chkVuotKhung.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_LUONGDONGBHXH, chkLuongDongBHXH.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_BACLUONG, chkBacLuong.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_BACLUONGNB, chkBacLuongNB.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_NGAYHL, chkNgayHL.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_NGAYHLNB, chkNgayHLNB.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_SOQD, chkSoQD.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_NGAYQD, chkNgayQD.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_NGAYHIEULUC, chkNgayHieuLuc.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_NGAYHETHIEULUC, chkNgayHetHieuLuc.Checked.ToString(), string.Join(",", arrDepartment)); controller.CreateOrSave(SystemConfigParameter.QDL_NGUOIQD, chkNguoiQD.Checked.ToString(), string.Join(",", arrDepartment)); Dialog.ShowNotification("Đã lưu cấu hình"); wdConfigGridPanel.Hide(); Response.Redirect(Request.RawUrl); } catch (Exception ex) { ExtNet.Msg.Alert("Thông báo từ hệ thống", "Có lỗi xảy ra: " + ex.Message).Show(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdateConfig_Click(object sender, DirectEventArgs e) { try { if (txtSystemMail.Text.Contains("@gmail.com") == false && !string.IsNullOrEmpty(txtSystemMail.Text)) { X.MessageBox.Alert("Thông báo", "Hệ thống chỉ chấp nhận định dạng gmail").Show(); return; } //SystemController htController = new SystemController(); var htController = new SystemConfigController(); var departments = string.Join(",", _userModel.Departments.Select(d => d.Id)); // tab thông tin chung htController.CreateOrSave(SystemConfigParameter.EMAIL, txtSystemMail.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.PASSWORD_EMAIL, txtPassword.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.MENU_TYPE, cbMenuType.SelectedItem.Value, departments); htController.CreateOrSave(SystemConfigParameter.COMPANY_NAME, txtCompanyName.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.CITY, txtCity.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.PREFIX, txtTienTo.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.NUMBER_OF_CHARACTER, txtSoLuong.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.COMPANY_ADDRESS, txt_DiaChi.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.COMPANY_MASOTHUE, txt_MaSoThue.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.COMPANY_DIENTHOAI, txt_DienThoai.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.COMPANY_FAX, txt_Fax.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.COMPANY_EMAIL, txt_Email.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.MNG_COMPANY_NAME, txtManagementCompanyName.Text.Trim(), departments); // tab sinh mã, số quyết định htController.CreateOrSave(SystemConfigParameter.SUFFIX_SOHOPDONG, txtSoHopDong.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.SUFFIX_SOQDLUONG, txtSoQuyetDinhLuong.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.SUFFIX_SOQDKHENTHUONG, txtSoQDKhenThuong.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.SUFFIX_SOQDKYLUAT, txtSoQDKyLuat.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.SUFFIX_SOQDCONGTAC, txtSoQDCongTac.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.SUFFIX_SOQDDIEUCHUYEN, txtSoQĐieuChuyen.Text.Trim(), departments); // tab cấu hình chữ ký báo cáo htController.CreateOrSave(SystemConfigParameter.SuDungTenDangNhap, chknguoidangnhap.Checked.ToString(), departments); htController.CreateOrSave(SystemConfigParameter.chuky1, txtnguoiky1.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.chuky2, txtnguoiky2.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.chuky3, txtnguoiky3.Text.Trim(), departments); htController.CreateOrSave(SystemConfigParameter.chuky4, txtnguoiky4.Text.Trim(), departments); wdWindow.Hide(); } catch (Exception ex) { X.MessageBox.Alert("Thông báo", ex.Message).Show(); } }
public void GenerateRewardDecisionNumber() { var departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); var suffix = SystemConfigController.GetValueByNameFollowDepartment(SystemConfigParameter.SUFFIX_SOHOPDONG, departments); if (string.IsNullOrEmpty(suffix)) { suffix = "QĐ"; } var decisioNumber = GenerateDecisionNumber(suffix); txtSoQuyetDinhHangLoat.Text = decisioNumber; }
public void GenerateSoQD() { var departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); var suffix = SystemConfigController.GetValueByNameFollowDepartment(SystemConfigParameter.SUFFIX_SOHOPDONG, departments); if (string.IsNullOrEmpty(suffix)) { suffix = SuffixDecision; } var contractNumber = GenerateContractNumber(suffix); txtHopDongSoHopDong.Text = contractNumber; }
private void sendEmailCreateAccount(UserInfo uInfo) { // send email to user //SystemController htController = new SystemController(); object mailFrom = SystemConfigController.GetValueByNameFollowDepartment(SystemConfigParameter.EMAIL, string.Join(",", CurrentUser.Departments.Select(d => d.Id))); string from = mailFrom != null?mailFrom.ToString() : ""; string mailPassword = SystemConfigController.GetValueByNameFollowDepartment(SystemConfigParameter.PASSWORD_EMAIL, string.Join(",", CurrentUser.Departments.Select(d => d.Id))); string fromEmailPassword = mailPassword != null ? mailPassword : ""; if (from == "" || fromEmailPassword != "") { from = "*****@*****.**"; fromEmailPassword = "******"; } string mailName = "Đăng ký tài khoản"; string subject = "Đăng ký tài khoản"; string content = Util.GetInstance().ReadFile(Server.MapPath( "../../Modules/MailTemplate/CreateAccount.vi-VN.html")); if (uInfo.DisplayName == null) { content = string.Format(content, uInfo.UserName, uInfo.UserName, uInfo.Password); } else { content = string.Format(content, uInfo.DisplayName, uInfo.UserName, uInfo.Password); } if (mailFrom != "" && mailPassword != "") { SoftCore.Utilities.Email.SendEmail(from, fromEmailPassword, mailName, uInfo.Email, subject, content); X.Msg.Alert("Cảnh báo", "Đã gửi mail đến người dùng!").Show(); } // end send email to user }
private void UpdateData() { SystemConfigurationUIDM datamodel = dmc.SaveData(new SystemConfigurationUIDM()); try { SystemConfigController ctlsys = new SystemConfigController(); int check = ctlsys.UpdateConfig(datamodel); if (check == 0) { MessageDialog.ShowInformation(this, null, Message.LoadMessage(TKPMessages.eValidate.VLM0100.ToString()).MessageDescription); return; } else { loadData(); } } catch (Exception ex) { MessageDialog.ShowBusiness(this, ex.Message); } }
public void LoadConfigGridPanel() { try { var departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); var list = SystemConfigController.GetAllByNameAndDepartment(NameCondition, departments); foreach (var item in list) { switch (item.Name) { case SystemConfigParameter.QDL_LUONGCUNG: chkLuongCung.Checked = bool.Parse(item.Value); break; case SystemConfigParameter.QDL_HESOLUONG: chkHeSoLuong.Checked = bool.Parse(item.Value); break; case SystemConfigParameter.QDL_PHANTRAMHL: chkPercentageSalary.Checked = bool.Parse(item.Value); break; case SystemConfigParameter.QDL_LUONGDONGBHXH: chkLuongDongBHXH.Checked = bool.Parse(item.Value); break; case SystemConfigParameter.QDL_BACLUONG: chkBacLuong.Checked = bool.Parse(item.Value); break; case SystemConfigParameter.QDL_BACLUONGNB: chkBacLuongNB.Checked = bool.Parse(item.Value); break; case SystemConfigParameter.QDL_NGAYHL: chkNgayHL.Checked = bool.Parse(item.Value); break; case SystemConfigParameter.QDL_NGAYHLNB: chkNgayHLNB.Checked = bool.Parse(item.Value); break; case SystemConfigParameter.QDL_SOQD: chkSoQD.Checked = bool.Parse(item.Value); break; case SystemConfigParameter.QDL_NGAYQD: chkNgayQD.Checked = bool.Parse(item.Value); break; case SystemConfigParameter.QDL_NGAYHIEULUC: chkNgayHieuLuc.Checked = bool.Parse(item.Value); break; case SystemConfigParameter.QDL_NGAYHETHIEULUC: chkNgayHetHieuLuc.Checked = bool.Parse(item.Value); break; case SystemConfigParameter.QDL_NGUOIQD: chkNguoiQD.Checked = bool.Parse(item.Value); break; } } } catch (Exception ex) { X.Msg.Alert("Thông báo từ hệ thống", "Có lỗi xảy ra: " + ex.Message).Show(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ImportFile(object sender, DirectEventArgs e) { try { var workbook = new WorkBook(); if (fileExcel.HasFile) { var path = UploadFile(fileExcel, Constant.PathTemplate); if (path == null) { return; } // Read data from excel workbook.readXLSX(Path.Combine(Server.MapPath("~/"), Constant.PathTemplate, path)); if (!txtSheetName.IsEmpty) { workbook.Sheet = workbook.findSheetByName(txtSheetName.Text); } // Export to datatable var dataTable = workbook.ExportDataTable(1, //first row 0, //first col workbook.LastRow, //last row workbook.LastCol + 1, //last col true, //first row as header true //convert to DateTime object if it match date pattern ); //check limit package var limitPackage = SystemConfigController.GetLimitPackage(); if (dataTable.Rows.Count > limitPackage) { Dialog.Alert("File Excel của bạn đã vượt quá giới hạn gói phần mềm đã đăng ký. Vui lòng đăng ký thêm để sử dụng."); return; } // count success create var successRecords = new List <int>(); foreach (DataRow row in dataTable.Rows) { // Check employee code var employeeCode = row["EmployeeCode"].ToString().Trim(); var idNumber = row["IDNumber"].ToString().Trim(); if (!string.IsNullOrEmpty(employeeCode)) { var recordList = RecordController.CheckExistIDNumberAndEmployeeCode(null, null, employeeCode); if (recordList != null && recordList.Count > 0) { continue; } } // Check id number if (!string.IsNullOrEmpty(idNumber)) { var recordList = RecordController.CheckExistIDNumberAndEmployeeCode(null, idNumber, null); if (recordList != null && recordList.Count > 0) { continue; } } // Create new record var record = new hr_Record { // Set default work status WorkStatusId = CatalogWorkStatusController.GetByGroup(RecordStatus.Working).Id }; foreach (DataColumn col in dataTable.Columns) { if (string.IsNullOrEmpty(row[col].ToString())) { continue; } var condition = " [Name] = N'{0}' ".FormatWith(row[col]); cat_Location location; switch (col.ColumnName) { case nameof(hr_Record.FullName): record.FullName = row[col].ToString(); // lấy họ và đệm từ họ tên var position = record.FullName.LastIndexOf(' '); record.Name = position == -1 ? record.FullName : record.FullName.Substring(position + 1).Trim(); break; case nameof(hr_Record.Sex): record.Sex = row[col].ToString().Equals("Nam"); break; case nameof(hr_Record.BirthPlaceWardId): location = cat_LocationServices.GetByCondition(condition); record.BirthPlaceWardId = location.Id; break; case nameof(hr_Record.BirthPlaceDistrictId): location = cat_LocationServices.GetByCondition(condition); record.BirthPlaceDistrictId = location.Id; break; case nameof(hr_Record.BirthPlaceProvinceId): location = cat_LocationServices.GetByCondition(condition); record.BirthPlaceProvinceId = location.Id; break; case nameof(hr_Record.HometownWardId): location = cat_LocationServices.GetByCondition(condition); record.HometownWardId = location.Id; break; case nameof(hr_Record.HometownDistrictId): location = cat_LocationServices.GetByCondition(condition); record.HometownDistrictId = location.Id; break; case nameof(hr_Record.HometownProvinceId): location = cat_LocationServices.GetByCondition(condition); record.HometownProvinceId = location.Id; break; default: // TODO : need create util function var reg = @"\(([^)]*)\)"; var propVal = row[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 = record.GetType().GetProperty(col.ColumnName); //find the property type if (propInfo == null) { break; } 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(row[col].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(record, propVal, null); break; } } // add record hr_RecordServices.Create(record); successRecords.Add(dataTable.Rows.IndexOf(row)); } Dialog.Alert("Thêm thành công " + successRecords.Count + " bản ghi"); grpImportExcel.Reload(); } else { Dialog.Alert("Bạn chưa chọn tệp tin đính kèm. Vui lòng chọn."); } } catch (Exception ex) { Dialog.ShowError("Đã có lỗi xảy ra: " + ex.Message); } }
/// <summary> /// Reset mật khẩu người dùng /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void mnuResetPassword_Click(object sender, DirectEventArgs e) { string userid = ""; string failUserId = ""; try { string[] ds = hdfListUserID.Text.Split(','); List <string> userIdList = new List <string>(); for (int i = 0; i < ds.Count(); i++) { if (ds[i] != "") { userIdList.Add(ds[i]); } } string mailContent = Util.GetInstance().ReadFile(Server.MapPath("EmailHTML/ResetPassword.htm")); string systemName = SystemConfigController .GetValueByNameFollowDepartment(SystemConfigParameter.COMPANY_NAME, string.Join(",", CurrentUser.Departments.Select(d => d.Id))) .ToString(); string systemEmail = SystemConfigController.GetValueByNameFollowDepartment(SystemConfigParameter.EMAIL, string.Join(",", CurrentUser.Departments.Select(d => d.Id))); string systemPassword = SystemConfigController.GetValueByNameFollowDepartment(SystemConfigParameter.PASSWORD_EMAIL, string.Join(",", CurrentUser.Departments.Select(d => d.Id))); foreach (var item in userIdList) { string password = Util.GetInstance().GetRandomString(7); UserInfo u = UsersController.GetInstance().GetUser(int.Parse(item)); if (Email.SendEmail(systemEmail, systemPassword, systemName, u.Email, "Thông báo mật khẩu mới", string.Format(mailContent, password, u.DisplayName))) { u.Password = password; UsersController.GetInstance().UpdateUser(u); userid += item + ", "; } else { failUserId += item + ", "; } } if (!string.IsNullOrEmpty(failUserId)) { X.MessageBox.Alert("Thông báo", "Các mã tài khoản sau không đổi đổi được mật khẩu: " + failUserId) .Show(); } else { X.MessageBox.Alert("Thông báo", "Đặt lại mật khẩu thành công").Show(); } //var accessDiary = new AccessHistory //{ // Function = "Đặt lại mật khẩu", // Description = "Đặt lại mật khẩu", // IsError = false, // UserName = CurrentUser.User.UserName, // Time = DateTime.Now, // BusinessCode = "Users", // ComputerName = Util.GetInstance().GetComputerName(Request.UserHostAddress), // ComputerIP = Request.UserHostAddress, // Referent = "Các UserId bị reset mật khẩu : " + userid //}; //AccessHistoryServices.Create(accessDiary); } catch (Exception ex) { //var accessDiary = new AccessHistory //{ // Function = "Đặt lại mật khẩu", // Description = ex.Message.Replace("'", " "), // IsError = true, // UserName = CurrentUser.User.UserName, // Time = DateTime.Now, // BusinessCode = "Users", // ComputerName = Util.GetInstance().GetComputerName(Request.UserHostAddress), // ComputerIP = Request.UserHostAddress, // Referent = "Các UserId bị reset mật khẩu : " + userid //}; //AccessHistoryServices.Create(accessDiary); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdateHopDong_Click(object sender, DirectEventArgs e) { try { var contract = new hr_Contract(); var controller = new ContractController(); var util = new ConvertUtils(); // upload file string path = string.Empty; if (fufHopDongTepTin.HasFile) { // string directory = Server.MapPath("../"); path = UploadFile(fufHopDongTepTin, Constant.PathContract); } contract.RecordId = Convert.ToInt32(hdfPrKey.Text); if (!string.IsNullOrEmpty(hdfCbxJobId.Text)) { contract.JobId = Convert.ToInt32(hdfCbxJobId.Text); } if (!string.IsNullOrEmpty(hdfContractTypeId.Text)) { contract.ContractTypeId = Convert.ToInt32(hdfContractTypeId.Text); } if (!string.IsNullOrEmpty(hdfContractStatusId.Text)) { contract.ContractStatusId = Convert.ToInt32(hdfContractStatusId.Text); } if (!util.IsDateNull(dfHopDongNgayHopDong.SelectedDate)) { contract.ContractDate = dfHopDongNgayHopDong.SelectedDate; } if (!string.IsNullOrEmpty(hdfRecruitmentTypeId.Text)) { contract.RecruitmentTypeId = Convert.ToInt32(hdfRecruitmentTypeId.Text); } // sinh số hợp đồng string departments = string.Join(",", CurrentUser.Departments.Select(d => d.Id)); string suffix = SystemConfigController.GetValueByNameFollowDepartment(SystemConfigParameter.SUFFIX_SOHOPDONG, departments); contract.ContractNumber = GenerateContractNumber(suffix); if (!string.IsNullOrEmpty(txtHopDongSoHopDong.Text)) { contract.ContractNumber = txtHopDongSoHopDong.Text; } if (!util.IsDateNull(dfHopDongNgayKiKet.SelectedDate)) { contract.ContractEndDate = dfHopDongNgayKiKet.SelectedDate; } if (!util.IsDateNull(dfNgayCoHieuLuc.SelectedDate)) { contract.EffectiveDate = dfNgayCoHieuLuc.SelectedDate; } contract.PersonRepresent = txt_NguoiKyHD.Text; if (!string.IsNullOrEmpty(hdfCbxPositionId.Text)) { contract.PersonPositionId = Convert.ToInt32(hdfCbxPositionId.Text); } contract.AttachFileName = path != "" ? path : hdfHopDongTepTinDK.Text; contract.Note = txtHopDongGhiChu.Text; contract.CreatedBy = CurrentUser.User.UserName; contract.CreatedDate = DateTime.Now; if (e.ExtraParams["Command"] == "Update") { contract.Id = int.Parse("0" + hdfRecordId.Text); controller.Update(contract); wdHopDong.Hide(); } else { // kiểm tra còn hợp đồng nào chưa hết hạn không var checkContract = controller.CheckContractBeforeInsert(Convert.ToInt32(hdfRecordId.Text), contract.EffectiveDate); if (checkContract != null) // cán bộ còn ít nhất 1 hợp đồng có giá trị { ExtNet.Msg.Alert("Thông báo", "Hợp đồng hiện tại của cán bộ vẫn còn hiệu lực. Bạn không được phép thay đổi hợp đồng.") .Show(); return; } controller.Insert(contract); if (e.ExtraParams["Close"] == "True") { wdHopDong.Hide(); } else { GenerateSoQD(); } } grpContract.Reload(); } catch (Exception ex) { ExtNet.Msg.Alert("Thông báo từ hệ thống", "Có lỗi xảy ra: " + ex.Message).Show(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSaveEmployee_Click(object sender, DirectEventArgs e) { var record = new RecordModel(); var candidate = new CandidateModel(); if (!string.IsNullOrEmpty(hdfRecordId.Text)) { record.EmployeeCode = txtEmployeeCode.Text; if (!string.IsNullOrEmpty(txtEmployeeCode.Text.Trim())) { var recordList = RecordController.CheckExistIDNumberAndEmployeeCode(null, null, txtEmployeeCode.Text); if (recordList != null && recordList.Count > 1) { Dialog.ShowError("Mã nhân viên đã tồn tại. Vui lòng nhập mã khác."); txtEmployeeCode.Text = GenerateEmployeeCode(); return; } } } else { record.EmployeeCode = txtEmployeeCode.Text; if (!string.IsNullOrEmpty(txtEmployeeCode.Text.Trim())) { var recordList = RecordController.CheckExistIDNumberAndEmployeeCode(null, null, txtEmployeeCode.Text); if (recordList != null && recordList.Count > 0) { Dialog.ShowError("Mã nhân viên đã tồn tại. Vui lòng nhập mã khác."); return; } } if (!string.IsNullOrEmpty(txtIDNumber.Text.Trim())) { var recordList = RecordController.CheckExistIDNumberAndEmployeeCode(null, txtIDNumber.Text, null); if (recordList != null && recordList.Count > 0) { Dialog.ShowError("Số chứng minh nhân dân đã tồn tại. Vui lòng nhập số chứng minh nhân dân khác."); return; } } } if (!string.IsNullOrEmpty(hdfImagePerson.Text)) { record.ImageUrl = hdfImagePerson.Text; } record.FullName = txtFullName.Text; // lấy họ và đệm từ họ tên var position = record.FullName.LastIndexOf(' '); record.Name = position == -1 ? record.FullName : record.FullName.Substring(position + 1).Trim(); record.Alias = txtAlias.Text; if (!DatetimeHelper.IsNull(dfBirthDate.SelectedDate)) { record.BirthDate = dfBirthDate.SelectedDate; } if (!string.IsNullOrEmpty(cbxSex.SelectedItem.Value) && cbxSex.SelectedItem.Value == "M") { record.Sex = true; } else { record.Sex = false; } if (string.IsNullOrEmpty(cbxBasicEducation.Text)) { hdfBasicEducationId.Text = @"0"; } if (string.IsNullOrEmpty(cbxEducation.Text)) { hdfEducationId.Text = @"0"; } if (string.IsNullOrEmpty(cbxInputIndustry.Text)) { hdfInputIndustryId.Text = @"0"; } if (string.IsNullOrEmpty(cbxITLevel.Text)) { hdfITLevelId.Text = @"0"; } if (string.IsNullOrEmpty(cbxLanguageLevel.Text)) { hdfLanguageLevelId.Text = @"0"; } if (string.IsNullOrEmpty(cbxPosition.Text)) { hdfPositionId.Text = @"0"; } if (string.IsNullOrEmpty(cbxJobTitle.Text)) { hdfJobTitleId.Text = @"0"; } if (!string.IsNullOrEmpty(hdfBirthPlaceProvinceId.Text)) { record.BirthPlaceProvinceId = Convert.ToInt32(hdfBirthPlaceProvinceId.Text); } if (string.IsNullOrEmpty(cbxBirthPlaceDistrict.Text)) { hdfBirthPlaceDistrictId.Text = @"0"; } if (!string.IsNullOrEmpty(hdfBirthPlaceDistrictId.Text)) { record.BirthPlaceDistrictId = Convert.ToInt32(hdfBirthPlaceDistrictId.Text); } if (string.IsNullOrEmpty(cbxBirthPlaceWard.Text)) { hdfBirthPlaceWardId.Text = @"0"; } if (!string.IsNullOrEmpty(hdfBirthPlaceWardId.Text)) { record.BirthPlaceWardId = Convert.ToInt32(hdfBirthPlaceWardId.Text); } if (!string.IsNullOrEmpty(hdfHometownProvinceId.Text)) { record.HometownProvinceId = Convert.ToInt32(hdfHometownProvinceId.Text); } if (string.IsNullOrEmpty(cbxHometownDistrict.Text)) { hdfHometownDistrictId.Text = @"0"; } if (!string.IsNullOrEmpty(hdfHometownDistrictId.Text)) { record.HometownDistrictId = Convert.ToInt32(hdfHometownDistrictId.Text); } if (string.IsNullOrEmpty(cbxHometownWard.Text)) { hdfHometownWardId.Text = @"0"; } if (!string.IsNullOrEmpty(hdfHometownWardId.Text)) { record.HometownWardId = Convert.ToInt32(hdfHometownWardId.Text); } if (!string.IsNullOrEmpty(hdfMaritalStatusId.Text)) { record.MaritalStatusId = Convert.ToInt32(hdfMaritalStatusId.Text); } if (!string.IsNullOrEmpty(hdfFolkId.Text)) { record.FolkId = Convert.ToInt32(hdfFolkId.Text); } if (!string.IsNullOrEmpty(hdfReligionId.Text)) { record.ReligionId = Convert.ToInt32(hdfReligionId.Text); } record.ResidentPlace = txt_ResidentPlace.Text; record.Address = txt_Address.Text; record.CPVCardNumber = txtCPVCardNumber.Text; if (!string.IsNullOrEmpty(hdfJobTitleId.Text)) { record.JobTitleId = Convert.ToInt32(hdfJobTitleId.Text); } //Ngay thu viec if (!DatetimeHelper.IsNull(RecruimentDate.SelectedDate)) { record.RecruimentDate = RecruimentDate.SelectedDate; } //Ngay chinh thuc if (!DatetimeHelper.IsNull(ParticipationDate.SelectedDate)) { record.ParticipationDate = ParticipationDate.SelectedDate; } record.RecruimentDepartment = txtRecruitmentDepartment.Text; if (!string.IsNullOrEmpty(hdfBasicEducationId.Text)) { record.BasicEducationId = Convert.ToInt32(hdfBasicEducationId.Text); } if (!string.IsNullOrEmpty(hdfEducationId.Text)) { record.EducationId = Convert.ToInt32(hdfEducationId.Text); } if (!string.IsNullOrEmpty(hdfPoliticLevelId.Text)) { record.PoliticLevelId = Convert.ToInt32(hdfPoliticLevelId.Text); } if (!string.IsNullOrEmpty(hdfLanguageLevelId.Text)) { record.LanguageLevelId = Convert.ToInt32(hdfLanguageLevelId.Text); } if (!string.IsNullOrEmpty(hdfITLevelId.Text)) { record.ITLevelId = Convert.ToInt32(hdfITLevelId.Text); } if (!DatetimeHelper.IsNull(CPVJoinedDate.SelectedDate)) { record.CPVJoinedDate = CPVJoinedDate.SelectedDate; } if (!DatetimeHelper.IsNull(CPVOfficialJoinedDate.SelectedDate)) { record.CPVOfficialJoinedDate = CPVOfficialJoinedDate.SelectedDate; } record.CPVJoinedPlace = txtCPVJoinedPlace.Text; if (!string.IsNullOrEmpty(hdfCPVPositionId.Text)) { record.CPVPositionId = Convert.ToInt32(hdfCPVPositionId.Text); } if (!string.IsNullOrEmpty(hdfVYUPositionId.Text)) { record.VYUPositionId = Convert.ToInt32(hdfVYUPositionId.Text); } if (!DatetimeHelper.IsNull(ArmyJoinedDate.SelectedDate)) { record.ArmyJoinedDate = ArmyJoinedDate.SelectedDate; } if (!DatetimeHelper.IsNull(ArmyLeftDate.SelectedDate)) { record.ArmyLeftDate = ArmyLeftDate.SelectedDate; } if (!string.IsNullOrEmpty(hdfPositionId.Text)) { record.PositionId = Convert.ToInt32(hdfPositionId.Text); } if (!string.IsNullOrEmpty(hdfArmyLevelId.Text)) { record.ArmyLevelId = Convert.ToInt32(hdfArmyLevelId.Text); } if (!string.IsNullOrEmpty(hdfHealthStatusId.Text)) { record.HealthStatusId = Convert.ToInt32(hdfHealthStatusId.Text); } record.BloodGroup = cbxBloodGroup.SelectedIndex >= 0 ? cbxBloodGroup.SelectedItem.Value : ""; if (!string.IsNullOrEmpty(txtHeight.Text)) { record.Height = Convert.ToDecimal(txtHeight.Text); } if (!string.IsNullOrEmpty(txtWeight.Text)) { record.Weight = Convert.ToDecimal(txtWeight.Text); } record.DepartmentId = !string.IsNullOrEmpty(hdfDepartmentId.Text) ? Convert.ToInt32(hdfDepartmentId.Text) : CurrentUser.RootDepartment.Id; record.RankWounded = txtRankWounded.Text; if (!string.IsNullOrEmpty(hdfFamilyPolicyId.Text)) { record.FamilyPolicyId = Convert.ToInt32(hdfFamilyPolicyId.Text); } if (!string.IsNullOrEmpty(txtIDNumber.Text)) { record.IDNumber = txtIDNumber.Text; } if (!DatetimeHelper.IsNull(IDIssueDate.SelectedDate)) { record.IDIssueDate = IDIssueDate.SelectedDate; } if (!string.IsNullOrEmpty(hdfIDIssuePlaceId.Text)) { record.IDIssuePlaceId = Convert.ToInt32(hdfIDIssuePlaceId.Text); } if (!DatetimeHelper.IsNull(VYUJoinedDate.SelectedDate)) { record.VYUJoinedDate = VYUJoinedDate.SelectedDate; } record.VYUJoinedPlace = txtVYUJoinedPlace.Text; record.PersonalTaxCode = txtPersonalTaxCode.Text; var workStatus = CatalogController.GetAll("cat_WorkStatus", null, ((int)RecordStatus.Working).ToString(), null, false, null, 1); if (workStatus.Count > 0) { record.WorkStatusId = workStatus.First().Id; } record.WorkEmail = txtWorkEmail.Text; record.PersonalEmail = txtPersonalEmail.Text; record.CellPhoneNumber = txtCellPhoneNumber.Text; record.HomePhoneNumber = txtHomePhoneNumber.Text; record.WorkPhoneNumber = txtWorkPhoneNumber.Text; record.InsuranceNumber = txtInsuranceNumber.Text; record.ContactPersonName = txtContactPersonName.Text; record.ContactPhoneNumber = txtContactPhoneNumber.Text; record.ContactRelation = txtContactRelation.Text; record.ContactAddress = txtContactAddress.Text; if (!string.IsNullOrEmpty(hdfInputIndustryId.Text)) { record.IndustryId = Convert.ToInt32(hdfInputIndustryId.Text); } if (!DatetimeHelper.IsNull(InsuranceIssueDate.SelectedDate)) { record.InsuranceIssueDate = InsuranceIssueDate.SelectedDate; } //other info if (!string.IsNullOrEmpty(hdfConstructionId.Text)) { record.ConstructionId = Convert.ToInt32(hdfConstructionId.Text); } if (!string.IsNullOrEmpty(hdfTeamId.Text)) { record.TeamId = Convert.ToInt32(hdfTeamId.Text); } if (!string.IsNullOrEmpty(txtStudyWorkingDay.Text)) { record.StudyWorkingDay = Convert.ToInt32(txtStudyWorkingDay.Text); } //Thoi gian thu viec if (!string.IsNullOrEmpty(txtProbationWorkingTime.Text)) { record.ProbationWorkingTime = Convert.ToInt32(txtProbationWorkingTime.Text); } if (!string.IsNullOrEmpty(hdfWorkingFormId.Text)) { record.WorkingFormId = (WorkingFormType)Enum.Parse(typeof(WorkingFormType), hdfWorkingFormId.Text); } if (!string.IsNullOrEmpty(hdfWorkLocationId.Text)) { record.WorkLocationId = Convert.ToInt32(hdfWorkLocationId.Text); } if (!string.IsNullOrEmpty(txtGraduationYear.Text)) { record.GraduationYear = Convert.ToInt32(txtGraduationYear.Text); } if (!string.IsNullOrEmpty(hdfGraduationTypeId.Text)) { record.GraduationTypeId = Convert.ToInt32(hdfGraduationTypeId.Text); } if (!string.IsNullOrEmpty(hdfUniversityId.Text)) { record.UniversityId = Convert.ToInt32(hdfUniversityId.Text); } if (!DatetimeHelper.IsNull(dfUnionJoinedDate.SelectedDate)) { record.UnionJoinedDate = dfUnionJoinedDate.SelectedDate; } if (!string.IsNullOrEmpty(hdfUnionPosition.Text)) { record.UnionJoinedPositionId = Convert.ToInt32(hdfUnionPosition.Text); } //BHYT record.HealthInsuranceNumber = txtHealthInsuranceNumber.Text; if (!DatetimeHelper.IsNull(dfHealthJoinedDate.SelectedDate)) { record.HealthJoinedDate = dfHealthJoinedDate.SelectedDate; } if (!DatetimeHelper.IsNull(dfHealthExpiredDate.SelectedDate)) { record.HealthExpiredDate = dfHealthExpiredDate.SelectedDate; } // Tuyển dụng if (!string.IsNullOrEmpty(txtCandidateCode.Text)) { candidate.Code = txtCandidateCode.Text; } if (!string.IsNullOrEmpty(txtDesiredSalary.Text)) { candidate.DesiredSalary = Convert.ToDecimal(txtDesiredSalary.Text); } if (!string.IsNullOrEmpty(hdfRequiredRecruitmentId.Text)) { candidate.RequiredRecruitmentId = Convert.ToInt32(hdfRequiredRecruitmentId.Text); } if (!DatetimeHelper.IsNull(dfApplyDate.SelectedDate)) { candidate.ApplyDate = dfApplyDate.SelectedDate; } if (!string.IsNullOrEmpty(hdfCandidateStatus.Text)) { candidate.Status = (CandidateType)Enum.Parse(typeof(CandidateType), hdfCandidateStatus.Text); } // Kiểm tra tuyển dụng if (int.TryParse(hdfType.Text, out var type) && type == 1) { record.Type = RecordType.Candidate; } var recordId = 0; var limitCount = SystemConfigController.GetLimitPackage(); if (Request.QueryString["Event"] == "Edit" || !string.IsNullOrEmpty(hdfRecordId.Text)) { //Update Ho so record.Id = Convert.ToInt32(hdfRecordId.Text); RecordController.Update(record); recordId = record.Id; // lấy record id thông tin ứng viên candidate.RecordId = Convert.ToInt32(hdfRecordId.Text); Dialog.ShowNotification("Cập nhật dữ liệu thành công!"); } else { var recordCount = RecordController.GetCountRecords((int)RecordType.Default); //check over limit package if (recordCount > limitCount) { Dialog.Alert("Gói phần mềm bạn đăng ký đã vượt quá giới hạn. Vui lòng đăng ký thêm để sử dụng."); return; } //create var newRecord = RecordController.Create(record); recordId = newRecord.Id; // lấy record id thông tin ứng viên candidate.RecordId = newRecord.Id; Dialog.ShowNotification("Thêm mới thành công!"); } // tuyển dụng if (type == 1) { if (int.TryParse(hdfCandidateId.Text, out var result) && result > 0) { candidate.Id = result; //update CandidateController.Update(candidate); } else { //count candidate exist var recordCount = RecordController.GetCountRecords((int)RecordType.Candidate); //check over limit package if (recordCount > limitCount) { Dialog.Alert("Gói phần mềm bạn đăng ký đã vượt quá giới hạn. Vui lòng đăng ký thêm để sử dụng."); return; } //create CandidateController.Create(candidate); } } // Save family SaveGridFamilyRelationship(e.ExtraParams["jsonFamilyRelationship"], recordId); if (e.ExtraParams["Reset"] == "True") { hdfRecordId.Text = ""; GridPanelFamilyRelationship.Reload(); } //set tabindex default tab_Employee.SetActiveTab(panelEmployee); //reset hdfImagePerson.Reset(); fufUploadControl.Reset(); img_anhdaidien.ImageUrl = ""; //close window wdInput.Hide(); UserControlClose(); }