Exemple #1
0
 protected void btnDeleteQuantum_Click(object sender, DirectEventArgs e)
 {
     try
     {
         var sm             = GridPanel1.SelectionModel.Primary as CellSelectionModel;
         var groupQuantumId = Convert.ToInt32(sm.SelectedCell.RecordID);
         var tmpBac         = sm.SelectedCell.Name;
         if (tmpBac.StartsWith("Bac"))
         {
             var bac = int.Parse(tmpBac.Replace("Bac", "").Trim());
             cat_GroupQuantumGrade groupQuantumGrade = GetSalaryGroupQuantumByCondition(groupQuantumId, null, bac);
             if (groupQuantumGrade == null)
             {
                 X.Msg.Alert("Thông báo từ hệ thống", "Không tìm thấy dữ liệu").Show();
                 return;
             }
             cat_GroupQuantumGradeServices.Delete(groupQuantumGrade.Id);
             var quantumName = cat_GroupQuantumServices.GetFieldValueById(groupQuantumGrade.GroupQuantumId);
             Dialog.ShowNotification("Đã xóa dữ liệu của ngạch: " + quantumName + ", bậc : " + groupQuantumGrade.SalaryGrade);
             GridPanel1.Reload();
         }
         else
         {
             Dialog.ShowNotification("Dữ liệu này không thể xóa!");
         }
     }
     catch (Exception ex)
     {
         X.Msg.Alert("Thông báo từ hệ thống", "Có lỗi xảy ra: " + ex.Message).Show();
     }
 }
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static CatalogGroupQuantumGradeModel Update(CatalogGroupQuantumGradeModel model)
        {
            // get existed by name
            var existedEntity = GetUnique(model.GroupQuantumId, model.Grade);

            // check existed
            if (existedEntity == null || existedEntity.Id == model.Id)
            {
                // init new entity
                var entity = new cat_GroupQuantumGrade();

                // set entity props
                model.FillEntity(ref entity);

                // update
                return(new CatalogGroupQuantumGradeModel(cat_GroupQuantumGradeServices.Update(entity)));
            }

            // report name existed
            return(null);
        }
        /// <summary>
        /// Create
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static CatalogGroupQuantumGradeModel Create(CatalogGroupQuantumGradeModel model)
        {
            // get existed by name
            var existedEntity = GetUnique(model.GroupQuantumId, model.Grade);

            // check existed
            if (existedEntity == null)
            {
                // init entity
                var entity = new cat_GroupQuantumGrade();

                // get entity from db
                model.FillEntity(ref entity);

                // return
                return(new CatalogGroupQuantumGradeModel(cat_GroupQuantumGradeServices.Create(entity)));
            }

            // report name existed
            return(null);
        }
Exemple #4
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();
            }
        }