Ejemplo n.º 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 CriterionModel();

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

                // set new props for entity
                model.Code         = txtName.Text.ToUpperString();
                model.ValueType    = (KpiValueType)Enum.Parse(typeof(KpiValueType), hdfValueType.Text);
                model.Name         = txtName.Text;
                model.Description  = txtDescription.Text;
                model.Formula      = txtFormula.Text;
                model.Order        = !string.IsNullOrEmpty(txtOrder.Text) ? Convert.ToInt32(txtOrder.Text) : 0;
                model.Status       = chkIsActive.Checked ? KpiStatus.Active : KpiStatus.Locked;
                model.FormulaRange = hdfFormulaRange.Text;

                // check entity id
                if (model.Id > 0)
                {
                    model.EditedDate = DateTime.Now;
                    model.EditedBy   = CurrentUser.User.UserName;
                    // update
                    CriterionController.Update(model);
                }
                else
                {
                    model.CreatedBy   = CurrentUser.User.UserName;
                    model.CreatedDate = DateTime.Now;
                    model.EditedDate  = DateTime.Now;
                    model.EditedBy    = "";
                    // insert
                    CriterionController.Create(model);
                }
                // hide window
                wdSetting.Hide();

                //reset form
                ResetForm();
                // reload data
                gpCriterion.Reload();
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }
Ejemplo n.º 2
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 tiêu chí đánh giá";
                    wdSetting.Icon  = Icon.Pencil;
                    var model = CriterionController.GetById(Convert.ToInt32(hdfId.Text));
                    if (model != null)
                    {
                        // set props
                        txtCode.Text        = model.Code;
                        txtFormula.Text     = model.Formula;
                        txtOrder.Text       = model.Order.ToString();
                        cboValueType.Text   = model.ValueTypeName;
                        hdfValueType.Text   = ((int)model.ValueType).ToString();
                        txtName.Text        = model.Name;
                        txtDescription.Text = model.Description;
                        if (model.Status == KpiStatus.Active)
                        {
                            chkIsActive.Checked = true;
                        }
                        hdfFormulaRange.Text = model.FormulaRange;
                    }
                }
                else
                {
                    // insert
                    wdSetting.Title = @"Thêm mới tiêu chí đánh giá";
                    wdSetting.Icon  = Icon.Add;
                }

                // show window
                wdSetting.Show();
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void EvaluationClick(object sender, DirectEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(hdfId.Text))
                {
                    //create new all employee
                    var records   = RecordController.GetAll(null, null, DepartmentIds, RecordType.Default, null, null);
                    var criterion = CriterionController.GetById(Convert.ToInt32(hdfId.Text));

                    foreach (var item in records)
                    {
                        var model = new EvaluationModel()
                        {
                            RecordId    = item.Id,
                            CriterionId = Convert.ToInt32(hdfId.Text),
                            Month       = DateTime.Now.Month,
                            Year        = DateTime.Now.Year,
                            Value       = ""
                        };

                        //get value
                        GetValueCriterionWorkbook(model, criterion, null);

                        //check exist
                        var evaluation = EvaluationController.CheckExist(model.RecordId, model.CriterionId, model.Month, model.Year);
                        if (evaluation != null)
                        {
                            model.Id = evaluation.Id;
                            //update
                            EvaluationController.Update(model);
                        }
                        else
                        {
                            //create
                            EvaluationController.Create(model);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }