/// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static SalaryBoardConfigModel Create(SalaryBoardConfigModel model)
        {
            var entity = new hr_SalaryBoardConfig();

            model.FillEntity(ref entity);
            return(new SalaryBoardConfigModel(hr_SalaryBoardConfigServices.Create(entity)));
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        private void Insert()
        {
            var config = new hr_SalaryBoardConfig()
            {
                CreatedDate = DateTime.Now
            };

            //Edit data
            EditData(config);
            //Create
            hr_SalaryBoardConfigServices.Create(config);
            ResetForm();
            gridSalaryConfig.Reload();
            wdSalaryBoardConfig.Hide();
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="config"></param>
        private void EditData(hr_SalaryBoardConfig config)
        {
            config.ColumnCode  = txtColumnCode.Text;
            config.ColumnExcel = cboExcelColumn.Text;
            config.Description = txtDescription.Text;
            config.Display     = txtDisplay.Text;
            config.Formula     = txtFormula.Text;
            config.IsInUsed    = chk_IsInUsed.Checked;
            config.IsReadOnly  = chk_IsReadOnly.Checked;
            config.Order       = !string.IsNullOrEmpty(txtOrder.Text) ? Convert.ToInt32(txtOrder.Text) : 0;
            if (!string.IsNullOrEmpty(hdfConfigId.Text))
            {
                config.ConfigId = Convert.ToInt32(hdfConfigId.Text);
            }
            if (!string.IsNullOrEmpty(cbxDataType.SelectedItem.Value))
            {
                switch (Convert.ToInt32(cbxDataType.SelectedItem.Value))
                {
                case (int)SalaryConfigDataType.Formula:
                    config.DataType = SalaryConfigDataType.Formula;
                    break;

                case (int)SalaryConfigDataType.FieldValue:
                    config.DataType   = SalaryConfigDataType.FieldValue;
                    config.ColumnCode = hdfChoseFieldFixed.Text;
                    break;

                case (int)SalaryConfigDataType.DynamicValue:
                    config.DataType = SalaryConfigDataType.DynamicValue;
                    break;

                case (int)SalaryConfigDataType.FixedValue:
                    config.DataType = SalaryConfigDataType.FixedValue;
                    break;

                case (int)SalaryConfigDataType.FieldFormula:
                    config.DataType   = SalaryConfigDataType.FieldFormula;
                    config.ColumnCode = hdfChoseFieldFormula.Text;
                    break;

                default:
                    config.DataType = 0;
                    break;
                }
            }
        }
示例#4
0
 private void SetValueColumnSalaryBoardDynamic(hr_SalaryBoardDynamic item, hr_SalaryBoardConfig boardConfig)
 {
     try
     {
         //get property item by class
         var property = item.GetType().GetProperties().FirstOrDefault(c => c.Name == boardConfig.ColumnCode);
         if (property != null)
         {
             var typeName = property.PropertyType.Name;
             if (typeName == "String")
             {
                 //convert string to type property
                 var changeType = Convert.ChangeType(txtValueAdjustment.Text,
                                                     typeof(String));
                 //set value to property
                 property.SetValue(item, changeType, null);
             }
             else
             {
                 //Truong hop gia tri nhap la chuoi thi default 0
                 double result;
                 if (!double.TryParse(txtValueAdjustment.Text, out result) || result < 0)
                 {
                     txtValueAdjustment.Text = "0";
                 }
                 //convert string to type property
                 var changeType = Convert.ChangeType(txtValueAdjustment.Text,
                                                     Nullable.GetUnderlyingType(property.PropertyType));
                 //set value to property
                 property.SetValue(item, changeType, null);
             }
         }
     }
     catch (Exception ex)
     {
         Dialog.ShowNotification("Có lỗi xảy ra" + ex.Message);
     }
 }