Exemplo n.º 1
0
        /// <summary>
        /// init setting window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InitWindow(object sender, DirectEventArgs e)
        {
            try
            {
                //reset form
                ResetForm();

                // init window props
                if (e.ExtraParams["Command"] == "Update")
                {
                    // edit
                    wdSetting.Title = @"Cập nhật lịch phỏng vấn";
                    wdSetting.Icon  = Icon.Pencil;
                    var model = InterviewController.GetById(Convert.ToInt32(hdfId.Text));
                    if (model != null)
                    {
                        // set props
                        txtName.Text = model.Name;
                        dfInterviewDate.SetValue(model.InterviewDate);
                        txtInterviewer.Text = model.Interviewer;
                        tfFromTime.Text     = model.FromTime.ToString("HH:mm");
                        tfToTime.Text       = model.ToTime.ToString("HH:mm");
                        hdfRecruitment.Text = model.RequiredRecruitmentId.ToString();
                        cboRecruitment.Text = model.RequiredRecruitmentName;
                    }
                    //reload
                    fsCandidate.Disabled = true;
                }
                else
                {
                    // insert
                    wdSetting.Title      = @"Thêm mới lịch phỏng vấn";
                    wdSetting.Icon       = Icon.Add;
                    fsCandidate.Disabled = false;
                }

                // show window
                wdSetting.Show();
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!ExtNet.IsAjaxRequest)
            {
                hdfOrder.Text         = Request.QueryString["order"];
                hdfDepartmentIds.Text = DepartmentIds;

                if (!string.IsNullOrEmpty(Request.QueryString["interviewId"]))
                {
                    var interviewModel =
                        InterviewController.GetById(Convert.ToInt32(Request.QueryString["interviewId"]));
                    if (interviewModel != null)
                    {
                        gpInterview.Title   = @"Chi tiết lịch phỏng vấn: " + interviewModel.Name;
                        hdfInterviewId.Text = interviewModel.Id.ToString();
                    }
                }
            }
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
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 interview     = InterviewController.GetById(Convert.ToInt32(hdfId.Text));
                    var interviewDate = new DateTime();
                    if (interview != null)
                    {
                        interviewDate = interview.InterviewDate;
                    }

                    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 candidate = CandidateController.GetByCode(employeeCode, CandidateType.Interview);
                        //check if value exists
                        var candidateInterviewModel = CandidateInterviewController.GetUnique(Convert.ToInt32(hdfId.Text), candidate.RecordId);
                        if (candidateInterviewModel != null)
                        {
                            //update value
                            EditDataToModel(dataTable, row, candidateInterviewModel, interviewDate);
                            candidateInterviewModel.EditedBy   = CurrentUser.User.UserName;
                            candidateInterviewModel.EditedDate = DateTime.Now;
                            CandidateInterviewController.Update(candidateInterviewModel);
                        }
                        else
                        {
                            var model = new CandidateInterviewModel()
                            {
                                RecordId    = candidate.RecordId,
                                InterviewId = Convert.ToInt32(hdfId.Text),
                                EditedBy    = CurrentUser.User.UserName,
                                EditedDate  = DateTime.Now,
                                CreatedBy   = CurrentUser.User.UserName,
                                CreatedDate = DateTime.Now
                            };

                            EditDataToModel(dataTable, row, model, interviewDate);
                            //create
                            CandidateInterviewController.Create(model);
                        }
                    }
                }
            }
            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();
            //close window
            wdImportExcelFile.Hide();
        }