Beispiel #1
0
        /// <summary>
        /// insert or update
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InsertOrUpdate(object sender, DirectEventArgs e)
        {
            try
            {
                // init entity
                var model = new InterviewModel();

                // check id
                if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0)
                {
                    var result = InterviewController.GetById(Convert.ToInt32(hdfId.Text));;
                    if (result != null)
                    {
                        model = result;
                    }
                }

                // set new props for entity
                model.Name = txtName.Text;
                if (!DatetimeHelper.IsNull(dfInterviewDate.SelectedDate))
                {
                    model.InterviewDate = dfInterviewDate.SelectedDate;
                }
                if (!string.IsNullOrEmpty(hdfRecruitment.Text))
                {
                    model.RequiredRecruitmentId = Convert.ToInt32(hdfRecruitment.Text);
                }
                var date = dfInterviewDate.SelectedDate;
                model.FromTime    = new DateTime(date.Year, date.Month, date.Day, tfFromTime.SelectedTime.Hours, tfFromTime.SelectedTime.Minutes, 0);
                model.ToTime      = new DateTime(date.Year, date.Month, date.Day, tfToTime.SelectedTime.Hours, tfToTime.SelectedTime.Minutes, 0);
                model.Interviewer = txtInterviewer.Text;

                var interviewId = 0;
                // check entity id
                if (model.Id > 0)
                {
                    model.EditedDate = DateTime.Now;
                    model.EditedBy   = CurrentUser.User.UserName;
                    // update
                    var result = InterviewController.Update(model);
                    interviewId = result.Id;
                }
                else
                {
                    model.CreatedBy   = CurrentUser.User.UserName;
                    model.CreatedDate = DateTime.Now;
                    model.EditedDate  = DateTime.Now;
                    model.EditedBy    = "";
                    // insert
                    var result = InterviewController.Create(model);
                    interviewId = result.Id;
                }

                if (interviewId > 0)
                {
                    if (!string.IsNullOrEmpty(hdfCandidate.Text))
                    {
                        var interviewTime = new DateTime(date.Year, date.Month, date.Day,
                                                         tfInterview.SelectedTime.Hours, tfInterview.SelectedTime.Minutes, 0);
                        var candidateModel = new CandidateInterviewModel()
                        {
                            InterviewId = interviewId
                        };
                        var candidate = CandidateController.GetById(Convert.ToInt32(hdfCandidate.Text));
                        if (candidate != null)
                        {
                            var candidateInterview = CandidateInterviewController.GetAll(null, interviewId, candidate.RecordId, false, null, null);
                            if (candidateInterview.Count > 0)
                            {
                                candidateModel = candidateInterview.First();
                                candidateModel.TimeInterview = interviewTime;
                                candidateModel.EditedDate    = DateTime.Now;
                                candidateModel.EditedBy      = CurrentUser.User.UserName;
                                //update
                                CandidateInterviewController.Update(candidateModel);
                            }
                            else
                            {
                                candidateModel.TimeInterview = interviewTime;
                                candidateModel.RecordId      = candidate.RecordId;
                                candidateModel.CreatedDate   = DateTime.Now;
                                candidateModel.CreatedBy     = CurrentUser.User.UserName;
                                candidateModel.EditedDate    = DateTime.Now;
                                candidateModel.EditedBy      = CurrentUser.User.UserName;

                                //create
                                CandidateInterviewController.Create(candidateModel);
                            }
                        }
                    }
                }

                // hide window
                wdSetting.Hide();

                //reset form
                ResetForm();
                // reload data
                gpInterview.Reload();
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }
Beispiel #2
0
        public void btnEdit_Click(RecordType type)
        {
            switch (type)
            {
            case RecordType.Default:
                wdInput.SetTitle("Cập nhật thông tin hồ sơ");
                hdfType.Text = @"0";
                break;

            case RecordType.Candidate:
                txtEmployeeCode.Hidden          = true;
                txtCandidateCode.Hidden         = false;
                panelJob.Disabled               = true;
                panelPolitic.Disabled           = true;
                panelEmployeeInsurance.Disabled = true;
                ctnCandidate.Hidden             = false;
                wdInput.SetTitle("Cập nhật thông tin ứng viên");
                hdfType.Text = @"1";
                break;

            default:
                break;
            }

            if (string.IsNullOrEmpty(hdfRecordId.Text))
            {
                return;
            }
            var hs = RecordController.GetById(Convert.ToInt32(hdfRecordId.Text));

            if (hs == null)
            {
                return;
            }
            // Ho so nhan su
            if (!string.IsNullOrEmpty(hs.ImageUrl))
            {
                img_anhdaidien.ImageUrl = @"~/" + Constant.PathLocationImageEmployee + @"/" + hs.ImageUrl;
            }
            txtEmployeeCode.Text = hs.EmployeeCode;
            txtFullName.Text     = hs.FullName;
            txtAlias.Text        = hs.Alias;
            cboDepartment.Text   = hs.DepartmentName;
            hdfDepartmentId.Text = hs.DepartmentId.ToString();
            dfBirthDate.SetValue(hs.BirthDateVn);
            cbxSex.Text             = hs.SexName == "Nam" ? @"M" : @"F";
            cboMaritalStatus.Text   = hs.MaritalStatusName;
            hdfMaritalStatusId.Text = hs.MaritalStatusId.ToString();
            txtCellPhoneNumber.Text = hs.CellPhoneNumber;
            txtHomePhoneNumber.Text = hs.HomePhoneNumber;
            txtWorkPhoneNumber.Text = hs.WorkPhoneNumber;
            cbxFolk.Text            = hs.FolkName;
            hdfFolkId.Text          = hs.FolkId.ToString();
            cbxReligion.Text        = hs.ReligionName;
            hdfReligionId.Text      = hs.ReligionId.ToString();
            txt_ResidentPlace.Text  = hs.ResidentPlace;
            txtCPVCardNumber.Text   = hs.CPVCardNumber;
            txtPersonalTaxCode.Text = hs.PersonalTaxCode;
            txtWorkEmail.Text       = hs.WorkEmail;
            txtPersonalEmail.Text   = hs.PersonalEmail;
            txt_Address.Text        = hs.Address;
            //Ngay thu viec
            RecruimentDate.SetValue(hs.RecruimentDate);
            //Ngay chinh thuc
            ParticipationDate.SetValue(hs.ParticipationDate);
            txtRecruitmentDepartment.Text = hs.RecruimentDepartment;
            cbxPosition.Text             = hs.PositionName;
            hdfPositionId.Text           = hs.PositionId.ToString();
            cbxBasicEducation.Text       = hs.BasicEducationName;
            hdfBasicEducationId.Text     = hs.BasicEducationId.ToString();
            cbxEducation.Text            = hs.EducationName;
            hdfEducationId.Text          = hs.EducationId.ToString();
            cbxPoliticLevel.Text         = hs.PoliticLevelName;
            hdfPoliticLevelId.Text       = hs.PoliticLevelId.ToString();
            cbxJobTitle.Text             = hs.JobTitleName;
            hdfJobTitleId.Text           = hs.JobTitleId.ToString();
            txtWorkStatus.Text           = hs.WorkStatusName;
            hdfWorkStatusId.Text         = hs.WorkStatusId.ToString();
            cbxBirthPlaceProvince.Text   = hs.BirthPlaceProvinceName;
            cbxBirthPlaceDistrict.Text   = hs.BirthPlaceDistrictName;
            cbxBirthPlaceWard.Text       = hs.BirthPlaceWardName;
            cbxHometownProvince.Text     = hs.HometownProvinceName;
            cbxHometownDistrict.Text     = hs.HometownDistrictName;
            cbxHometownWard.Text         = hs.HometownWardName;
            hdfBirthPlaceProvinceId.Text = hs.BirthPlaceProvinceId.ToString();
            hdfBirthPlaceDistrictId.Text = hs.BirthPlaceDistrictId.ToString();
            hdfBirthPlaceWardId.Text     = hs.BirthPlaceWardId.ToString();
            hdfHometownProvinceId.Text   = hs.HometownProvinceId.ToString();
            hdfHometownDistrictId.Text   = hs.HometownDistrictId.ToString();
            hdfHometownWardId.Text       = hs.HometownWardId.ToString();
            if (!string.IsNullOrEmpty(hdfBirthPlaceDistrictId.Text))
            {
                cbxBirthPlaceDistrict.Disabled = false;
            }
            if (!string.IsNullOrEmpty(hdfBirthPlaceWardId.Text))
            {
                cbxBirthPlaceWard.Disabled = false;
            }
            if (!string.IsNullOrEmpty(hdfHometownDistrictId.Text))
            {
                cbxHometownDistrict.Disabled = false;
            }
            if (!string.IsNullOrEmpty(hdfHometownWardId.Text))
            {
                cbxHometownWard.Disabled = false;
            }
            cbxITLevel.Text         = hs.ITLevelName;
            hdfITLevelId.Text       = hs.ITLevelId.ToString();
            cbxLanguageLevel.Text   = hs.LanguageLevelName;
            hdfLanguageLevelId.Text = hs.LanguageLevelId.ToString();
            cbxCPVPosition.Text     = hs.CPVPositionName;
            hdfCPVPositionId.Text   = hs.CPVPositionId.ToString();
            cbxVYUPosition.Text     = hs.VYUPositionName;
            hdfVYUPositionId.Text   = hs.VYUPositionId.ToString();
            cbxArmyLevel.Text       = hs.ArmyLevelName;
            hdfArmyLevelId.Text     = hs.ArmyLevelId.ToString();
            ArmyJoinedDate.SetValue(hs.ArmyJoinedDate);
            ArmyLeftDate.SetValue(hs.ArmyLeftDate);
            cbxHealthStatus.Text   = hs.HealthStatusName;
            hdfHealthStatusId.Text = hs.HealthStatusId.ToString();
            cbxFamilyPolicy.Text   = hs.FamilyPolicyName;
            hdfFamilyPolicyId.Text = hs.FamilyPolicyId.ToString();
            cbxIDIssuePlace.Text   = hs.IDIssuePlaceName;
            hdfIDIssuePlaceId.Text = hs.IDIssuePlaceId.ToString();
            CPVJoinedDate.SetValue(hs.CPVJoinedDate);
            CPVOfficialJoinedDate.SetValue(hs.CPVOfficialJoinedDate);
            txtCPVJoinedPlace.Text = hs.CPVJoinedPlace;
            VYUJoinedDate.SetValue(hs.VYUJoinedDate);
            txtVYUJoinedPlace.Text = hs.VYUJoinedPlace;
            cbxBloodGroup.SetValue(hs.BloodGroup);
            txtHeight.SetValue(hs.Height);
            txtWeight.SetValue(hs.Weight);
            txtRankWounded.Text = hs.RankWounded;
            txtIDNumber.SetValue(hs.IDNumber);
            IDIssueDate.SetValue(hs.IDIssueDate);
            txtInsuranceNumber.Text = hs.InsuranceNumber;
            InsuranceIssueDate.SetValue(hs.InsuranceIssueDate);
            txtContactAddress.Text     = hs.ContactAddress;
            txtContactPersonName.Text  = hs.ContactPersonName;
            txtContactPhoneNumber.Text = hs.ContactPhoneNumber;
            txtContactRelation.Text    = hs.ContactRelation;
            cbxInputIndustry.Text      = hs.IndustryName;
            hdfInputIndustryId.Text    = hs.IndustryId.ToString();
            hdfImagePerson.Text        = hs.ImageUrl;

            //Thong tin to doi
            hdfConstructionId.Text  = hs.ConstructionId.ToString();
            cbxConstruction.Text    = cat_ConstructionServices.GetFieldValueById(hs.ConstructionId, "Name");
            hdfTeamId.Text          = hs.TeamId.ToString();
            cbxTeam.Text            = cat_TeamServices.GetFieldValueById(hs.TeamId, "Name");
            txtStudyWorkingDay.Text = hs.StudyWorkingDay.ToString();
            txtGraduationYear.Text  = hs.GraduationYear.ToString();

            //BHYT
            txtHealthInsuranceNumber.Text = hs.HealthInsuranceNumber;
            dfHealthJoinedDate.SetValue(hs.HealthJoinedDate);
            dfHealthExpiredDate.SetValue(hs.HealthExpiredDate);

            //Xếp loại
            hdfGraduationTypeId.Text = hs.GraduationTypeId.ToString();
            cbxGraduationType.Text   = cat_GraduationTypeServices.GetFieldValueById(hs.GraduationTypeId, "Name");
            hdfUniversityId.Text     = hs.UniversityId.ToString();
            cbxUniversity.Text       = cat_UniversityServices.GetFieldValueById(hs.UniversityId, "Name");
            dfUnionJoinedDate.SetValue(hs.UnionJoinedDate);
            hdfUnionPosition.Text = hs.UnionJoinedPositionId.ToString();
            cboUnionPosition.Text = cat_PositionServices.GetFieldValueById(hs.UnionJoinedPositionId);

            //Thoi gian thu viec
            txtProbationWorkingTime.Text = hs.ProbationWorkingTime.ToString();
            hdfWorkingFormId.Text        = hs.WorkingFormId.ToString();
            cbxWorkingForm.Text          = ((WorkingFormType)Enum.Parse(typeof(WorkingFormType), hdfWorkingFormId.Text)).Description();
            hdfWorkLocationId.Text       = hs.WorkLocationId.ToString();
            cbxWorkLocation.Text         = cat_WorkLocationServices.GetFieldValueById(hs.WorkLocationId, "Name");

            // Tuyển dụng
            if (int.TryParse(hdfCandidateId.Text, out var result) && result > 0)
            {
                var candidate = CandidateController.GetById(result);
                if (candidate != null)
                {
                    txtCandidateCode.Text         = candidate.Code;
                    hdfRequiredRecruitmentId.Text = candidate.RequiredRecruitmentId.ToString();
                    cboRequiredRecruitment.Text   = candidate.RequiredRecruitmentName;
                    hdfCandidateStatus.Text       = candidate.Status.ToString();
                    cboCandidateStatus.Text       = candidate.StatusName;
                    txtDesiredSalary.SetValue(candidate.DesiredSalary);
                    dfApplyDate.SetValue(candidate.ApplyDate);
                }
            }
            //show window
            hdfEven.Text = "";

            wdInput.Show();
            //Quan he gia dinh
            GridPanelFamilyRelationship.Reload();
        }