Пример #1
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 tham số cho mục tiêu đánh giá";
                    wdSetting.Icon  = Icon.Pencil;
                    var model = ArgumentController.GetById(Convert.ToInt32(hdfId.Text));
                    if (model != null)
                    {
                        // set props
                        txtImportCode.Text    = model.Code;
                        cboCalculateCode.Text = model.CalculateCode;
                        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;
                        }
                    }
                }
                else
                {
                    // insert
                    wdSetting.Title = @"Thêm mới tham số cho mục tiêu đánh giá";
                    wdSetting.Icon  = Icon.Add;
                }

                // show window
                wdSetting.Show();
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void OnSelectArgument(object sender, DirectEventArgs e)
 {
     try
     {
         if (!string.IsNullOrEmpty(hdfArgumentId.Text))
         {
             var argument = ArgumentController.GetById(Convert.ToInt32(hdfArgumentId.Text));
             if (argument != null)
             {
                 txtValueType.Text = argument.ValueTypeName;
             }
         }
         else
         {
             txtValueType.Text = "";
         }
     }
     catch (Exception exception)
     {
         Dialog.ShowError(exception);
     }
 }
Пример #3
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 ArgumentModel();
                var resultModel = new ArgumentModel();

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

                // set new props for entity

                model.CalculateCode = cboCalculateCode.SelectedItem.Value;
                model.ValueType     = (KpiValueType)Enum.Parse(typeof(KpiValueType), hdfValueType.Text);
                model.Name          = txtName.Text;
                model.Code          = txtName.Text.ToUpperString();
                model.Description   = txtDescription.Text;
                model.Order         = !string.IsNullOrEmpty(txtOrder.Text) ? Convert.ToInt32(txtOrder.Text) : 0;
                model.Status        = chkIsActive.Checked ? KpiStatus.Active : KpiStatus.Locked;

                // check entity id
                if (model.Id > 0)
                {
                    model.EditedDate = DateTime.Now;
                    model.EditedBy   = CurrentUser.User.UserName;
                    // update
                    resultModel = ArgumentController.Update(model);
                }
                else
                {
                    model.CreatedBy   = CurrentUser.User.UserName;
                    model.CreatedDate = DateTime.Now;
                    model.EditedDate  = DateTime.Now;
                    model.EditedBy    = "";

                    // insert
                    resultModel = ArgumentController.Create(model);
                }

                if (resultModel != null)
                {
                    // show success notification
                    Dialog.ShowNotification("Lưu thành công");
                    // hide window
                    wdSetting.Hide();
                    //reset form
                    ResetForm();
                    // reload data
                    gpCriterionArgument.Reload();
                }
                else
                {
                    Dialog.ShowNotification("Lưu không thành công, mã tham số hoặc mã tính toán đã tồn tại");
                }
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }