protected void btnCapNhat_Click(object sender, DirectEventArgs e) { TieuChiDanhGiaInfo obj = new TieuChiDanhGiaInfo(); TieuChiDanhGiaController ctr = new TieuChiDanhGiaController(); obj.MaNhom = txtMaNhom.Text; obj.TenNhom = txtTenNhom.Text; if (!string.IsNullOrEmpty(txtHeSo.Text)) { obj.HeSo = decimal.Parse(txtHeSo.Text.Replace('.', ',')); } obj.GhiChu = txtGhiChu.Text; obj.CreatedDate = DateTime.Now; obj.CreatedBy = CurrentUser.ID; obj.MaDonVi = Session["MaDonVi"].ToString(); if (cbxTieuChiCha.Value != null) { obj.ParentID = cbxTieuChiCha.Value.ToString(); } else { obj.ParentID = "-1"; } if (e.ExtraParams["Command"] == "Edit") { obj.MaNhom = hdfRecordID.Text; ctr.Update(obj); wdAddWindow.Hide(); GridPanel1.Reload(); } else { DataTable tmp = new TieuChiDanhGiaController().GetByPrkey(obj.MaNhom); if (tmp.Rows.Count == 0) { ctr.Insert(obj); GridPanel1.Reload(); } else { X.Msg.Alert("Thông báo", "Mã tiêu chí đã tồn tại").Show(); } if (e.ExtraParams["Close"] == "True") { wdAddWindow.Hide(); cbxTieuChiCha.Reset(); } } grp_NhomTC.Reload(); }
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); } } }