Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InsertEvaluationByGroup(object sender, DirectEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(hdfGroupFilter.Text))
                {
                    var criterionModels = CriterionController.GetAll(null, Convert.ToInt32(hdfGroupFilter.Text), false,
                                                                     KpiStatus.Active, null, null, null);
                    //create new all employee
                    var records = RecordController.GetAll(null, null, DepartmentIds, RecordType.Default, null, null);
                    foreach (var criterion in criterionModels)
                    {
                        foreach (var item in records)
                        {
                            var model = new EvaluationModel()
                            {
                                RecordId    = item.Id,
                                CriterionId = criterion.Id,
                                Month       = DateTime.Now.Month,
                                Year        = DateTime.Now.Year,
                                Value       = ""
                            };

                            //get value
                            GetValueCriterionWorkbook(model, criterion, Convert.ToInt32(hdfGroupFilter.Text));

                            //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);
                            }
                        }
                    }
                    //hide window
                    wdEvaluation.Hide();
                    // reload grid
                    gpEvaluation.Reload();
                }
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }
Exemplo n.º 2
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);
            }
        }