Пример #1
0
 public void Insert(DAL.TieuChiDanhGia danhGia)
 {
     if (danhGia != null)
     {
         dataContext.TieuChiDanhGias.InsertOnSubmit(danhGia);
         Save();
     }
 }
Пример #2
0
 public void Update(DAL.TieuChiDanhGia danhGia)
 {
     DAL.TieuChiDanhGia temp = dataContext.TieuChiDanhGias.SingleOrDefault(t => t.MaNhom == danhGia.MaNhom);
     if (temp != null)
     {
         temp.GhiChu   = danhGia.GhiChu;
         temp.HeSo     = danhGia.HeSo;
         temp.MaNhom   = danhGia.MaNhom;
         temp.ParentID = danhGia.ParentID;
         temp.TenNhom  = danhGia.TenNhom;
         Save();
     }
 }
Пример #3
0
    protected void btnUpdateCriterion_Click(object sender, DirectEventArgs e)
    {
        try
        {
            DAL.TieuChiDanhGia       tieuChi    = new DAL.TieuChiDanhGia();
            TieuChiDanhGiaController controller = new TieuChiDanhGiaController();
            if (e.ExtraParams["Edit"] == "True")
            {
                tieuChi = controller.GetById(hdfRecordID.Text);
            }
            if (!string.IsNullOrEmpty(txtCriterionWeight.Text))
            {
                tieuChi.HeSo = decimal.Parse(txtCriterionWeight.Text.Replace('.', ','));
            }
            else
            {
                tieuChi.HeSo = 1;
            }
            tieuChi.TenNhom  = txtCriterionName.Text;
            tieuChi.ParentID = cbxCriterionGroup.SelectedItem.Value;
            tieuChi.GhiChu   = txtNote.Text;
            tieuChi.MaDonVi  = Session["MaDonVi"].ToString();

            if (e.ExtraParams["Edit"] == "True")
            {
                tieuChi.MaNhom      = hdfRecordID.Text;
                hdfTypeCommand.Text = "Edit";
                hdfClose.Text       = "True";
                // update criterion
                controller.Update(tieuChi);
                hdfInsertedID.Text = tieuChi.MaNhom;
                if (hdfIsEdit.Text != "True")
                {
                    Dialog.ShowNotification("Cập nhật thông tin tiêu chí đánh giá thành công");
                    wdAddNewEstimateCriterion.Hide();
                }
            }
            else
            {
                tieuChi.MaNhom      = txtCriterionCode.Text;
                hdfTypeCommand.Text = "Insert";
                // insert criterion
                tieuChi.CreatedBy   = CurrentUser.ID;
                tieuChi.CreatedDate = DateTime.Now;
                controller.Insert(tieuChi);
                hdfInsertedID.Text = tieuChi.MaNhom;
                if (hdfIsEdit.Text != "True")
                {
                    Dialog.ShowNotification("Thêm mới thành công tiêu chí đánh giá");
                }
                if (e.ExtraParams["Close"] == "True")
                {
                    hdfClose.Text = "True";
                    if (hdfIsEdit.Text != "True")
                    {
                        wdAddNewEstimateCriterion.Hide();
                    }
                }
                else
                {
                    hdfClose.Text = "False";
                }
            }
            RM.RegisterClientScriptBlock("save", "grpTestList.save();");
            if (hdfIsEdit.Text != "True")
            {
                if (hdfClose.Text != "True")
                {
                    RM.RegisterClientScriptBlock("rsform1", "ResetCriterionWindow();");
                }
                GridPanel1.Reload();
            }
        }
        catch (Exception ex)
        {
            if (ex.Message.ToLower().Contains("duplicate"))
            {
                Dialog.ShowError("Mã tiêu chí đánh giá đã bị trùng. Vui lòng nhập mã khác.");
            }
            else
            {
                Dialog.ShowError(ex.Message);
            }
        }
    }