/// <summary>
        /// Init setting window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InitWindow(object sender, DirectEventArgs e)
        {
            try
            {
                // init id
                var param = e.ExtraParams["Id"];
                // parse id
                if (int.TryParse(param, out var id))
                {
                    // init window props
                    if (id > 0)
                    {
                        // edit
                        wdSetting.Title = @"Sửa";
                        wdSetting.Icon  = Icon.Pencil;
                    }
                    else
                    {
                        // insert
                        wdSetting.Title = @"Thêm mới";
                        wdSetting.Icon  = Icon.Add;
                    }
                    // init id
                    hdfId.Text = id.ToString();

                    // init object
                    var model = new CatalogGroupQuantumGradeModel();

                    // check id
                    if (id > 0)
                    {
                        var result = CatalogGroupQuantumGradeController.GetById(id);
                        if (result != null)
                        {
                            model = result;
                        }
                    }

                    // set catalog props
                    hdfGroupQuantumId.Text = model.GroupQuantumId.ToString();
                    cboGroupQuantum.Text   = model.GroupQuantumName;
                    txtMonthStep.Text      = model.MonthStep.ToString();
                    txtGrade.Text          = model.Grade.ToString();
                    txtFactor.Text         = model.Factor.ToString("0.00");
                    hdfStatus.Text         = ((int)model.Status).ToString();
                    cboStatus.Text         = model.Status.Description();

                    // show window
                    wdSetting.Show();
                }
            }
            catch (Exception ex)
            {
                // show dilog
                Dialog.ShowError(ex);

                // log exception
                SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục mức lương nhóm ngạch - InitWindow", ex));
            }
        }
        /// <summary>
        /// Delete catalog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Delete(object sender, DirectEventArgs e)
        {
            try
            {
                // init id
                var param = e.ExtraParams["Id"];

                // parse id
                if (!int.TryParse(param, out var id) || id <= 0)
                {
                    // parse error, show error
                    Dialog.ShowError("Có lỗi xảy ra trong quá trình xử lý");
                    return;
                }

                // delete
                CatalogGroupQuantumGradeController.Delete(id);

                // reload data
                gpCatalog.Reload();
            }
            catch (Exception ex)
            {
                // show dilog
                Dialog.ShowError(ex);

                // log exception
                SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục mức lương nhóm ngạch - Delete", ex));
            }
        }
Example #3
0
 public void GetSalaryInfoHl()
 {
     if (!string.IsNullOrEmpty(hdfQuantumHLId.Text) && !string.IsNullOrEmpty(hdfSalaryGradeHL.Text))
     {
         var quantum      = cat_QuantumServices.GetById(Convert.ToInt32(hdfQuantumHLId.Text));
         var salaryFactor = CatalogGroupQuantumGradeController.GetUnique(quantum.GroupQuantumId,
                                                                         Convert.ToInt32(hdfSalaryGradeHL.Text)).Factor;
         txtHeSoLuongHL.SetValue(salaryFactor);
         var luong = Math.Round(salaryFactor * ConstSalaryBasic);
         txtMucLuongHL.SetValue(luong);
     }
     else
     {
         txtHeSoLuongHL.Text = "0";
         txtMucLuongHL.Text  = "0";
     }
 }
Example #4
0
 public void GetInformationSalaryMany()
 {
     if (!string.IsNullOrEmpty(hdfQuantumIdMany.Text) && !string.IsNullOrEmpty(hdfSalaryGradeMany.Text))
     {
         var quantum = CatalogQuantumController.GetById(Convert.ToInt32(hdfQuantumIdMany.Text));
         if (quantum == null)
         {
             return;
         }
         var groupQuantum = CatalogGroupQuantumGradeController.GetUnique(quantum.GroupQuantumId,
                                                                         Convert.ToInt32(hdfSalaryGradeMany.Text));
         if (groupQuantum == null)
         {
             return;
         }
         txtFactorMany.SetValue(groupQuantum.Factor);
         txtSalaryLevelMany.SetValue(Math.Round(groupQuantum.Factor * Convert.ToDecimal(hdfBasicSalary.Text)).ToString("##,###"));
     }
     else
     {
         txtFactorMany.Text      = @"0";
         txtSalaryLevelMany.Text = @"0";
     }
 }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCapNhat_Click(object sender, DirectEventArgs e)
        {
            try
            {
                if (e.ExtraParams["Command"] != "Edit")
                {
                    var groupQuantumId = 0;
                    var grade          = 0;
                    if (!string.IsNullOrEmpty(hdfGroupQuantumId.Text))
                    {
                        groupQuantumId = Convert.ToInt32(hdfGroupQuantumId.Text);
                    }
                    if (!string.IsNullOrEmpty(hdfBac.Text))
                    {
                        grade = Convert.ToInt32(hdfBac.Text);
                    }
                    var groupQuantum = GetSalaryGroupQuantumByCondition(groupQuantumId, null, grade);
                    if (groupQuantum != null)
                    {
                        X.Msg.Alert("Thông báo từ hệ thống", "Ngạch và bậc " + groupQuantum.SalaryGrade + " đã có dữ liệu. Bạn không thể thêm mới dữ liệu khác").Show();
                        return;
                    }
                }

                var salaryController = new CatalogGroupQuantumGradeController();
                var salary           = new cat_GroupQuantumGrade();
                if (!string.IsNullOrEmpty(hdfGroupQuantumId.Text))
                {
                    salary.GroupQuantumId = Convert.ToInt32(hdfGroupQuantumId.Text);
                }
                salary.SalaryLevel = txtMucLuong.Text;
                if (!string.IsNullOrEmpty(txtHeSoLuong.Text))
                {
                    salary.SalaryFactor = Convert.ToDecimal(txtHeSoLuong.Text.Replace('.', ','));
                }
                if (!string.IsNullOrEmpty(hdfBac.Text))
                {
                    salary.SalaryGrade = Convert.ToInt32(hdfBac.Text);
                }
                salary.Description = txtGhiChu.Text;
                salary.CreatedDate = DateTime.Now;

                if (e.ExtraParams["Command"] == "Edit")
                {
                    if (!string.IsNullOrEmpty(hdfRecordId.Text))
                    {
                        salary.Id = Convert.ToInt32(hdfRecordId.Text);
                    }
                    salaryController.Update(salary);
                    Dialog.ShowNotification("Cập nhật dữ liệu thành công");
                    wdThemMoiMucLuongNgach.Hide();
                }
                else
                {
                    if (cat_GroupQuantumServices.checkOutFrame(salary.GroupQuantumId, salary.SalaryGrade) == false)
                    {
                        Dialog.ShowError("Bậc bạn chọn đã vượt quá số bậc tối đa của ngạch");
                        return;
                    }
                    salaryController.Insert(salary);
                    Dialog.ShowNotification("Thêm mới dữ liệu thành công!");
                    if (e.ExtraParams["Close"] == "True")
                    {
                        wdThemMoiMucLuongNgach.Hide();
                    }
                    else
                    {
                        RM.RegisterClientScriptBlock("rs1", "ResetWdThemMucLuongNgach();");
                    }
                }
                GridPanel1.Reload();
            }
            catch (Exception ex)
            {
                X.Msg.Alert("Thông báo từ hệ thống", "Có lỗi xảy ra: " + ex.Message).Show();
            }
        }
        /// <summary>
        /// Insert or Update Catalog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InsertOrUpdate(object sender, DirectEventArgs e)
        {
            try
            {
                // init model
                var model = new CatalogGroupQuantumGradeModel
                {
                    EditedBy = CurrentUser.User.UserName
                };

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

                // get group quantum
                var groupQuantum = CatalogGroupQuantumController.GetById(Convert.ToInt32(hdfGroupQuantumId.Text));

                // check group quantum
                if (groupQuantum == null)
                {
                    // show alert
                    Dialog.ShowError("Chưa chọn nhóm ngạch");
                    return;
                }

                // set new props for model
                model.GroupQuantumId = groupQuantum.Id;
                model.MonthStep      = !string.IsNullOrEmpty(txtMonthStep.Text) && Convert.ToInt32(txtMonthStep.Text) > 0 ? Convert.ToInt32(txtMonthStep.Text) : groupQuantum.MonthStep;
                model.Grade          = !string.IsNullOrEmpty(txtGrade.Text) && Convert.ToInt32(txtGrade.Text) > 0 ? Convert.ToInt32(txtGrade.Text) : groupQuantum.GradeMax;
                model.Factor         = !string.IsNullOrEmpty(txtFactor.Text) ? Convert.ToDecimal(txtFactor.Text) : 0;
                model.Status         = !string.IsNullOrEmpty(hdfStatus.Text) ? (CatalogStatus)Convert.ToInt32(hdfStatus.Text) : CatalogStatus.Active;

                // check max grade
                if (model.Grade > groupQuantum.GradeMax)
                {
                    // show alert
                    Dialog.ShowError("Vượt quá bậc tối đa của nhóm ngạch");
                    return;
                }

                // check model id
                if (model.Id > 0)
                {
                    // update
                    CatalogGroupQuantumGradeController.Update(model);

                    // log action
                    SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục mức lương nhóm ngạch", SystemAction.Edit,
                                                                  "Sửa danh mục {0}".FormatWith(model.Name)));
                }
                else
                {
                    // set created user
                    model.CreatedBy = CurrentUser.User.UserName;

                    // insert
                    CatalogGroupQuantumGradeController.Create(model);

                    // log action
                    SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục mức lương nhóm ngạch", SystemAction.Create,
                                                                  "Tạo danh mục {0}".FormatWith(model.Name)));
                }

                // hide window
                wdSetting.Hide();

                // reload data
                gpCatalog.Reload();
            }
            catch (Exception ex)
            {
                // show dilog
                Dialog.ShowError(ex);

                // log exception
                SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục mức lương nhóm ngạch - InserOrUpdate", ex));
            }
        }