protected void btnDongYThemTieuChi_Click(object sender, DirectEventArgs e)
    {
        SelectedRowCollection    SelectedRow         = checkboxSelectionTieuChiDG.SelectedRows;
        TieuChiDanhGiaController tieuChiDGController = new TieuChiDanhGiaController();
        string str = "";

        foreach (var item in SelectedRow)
        {
            DataTable emp = tieuChiDGController.GetByPrkey(item.RecordID.ToString());
            if (emp.Rows.Count > 0)
            {
                string maTieuChi = emp.Rows[0]["MaNhom"].ToString();
                if (new TieuChi_DotDanhGiaController().CheckExistTieuChi_DotDanhGia(emp.Rows[0]["MaNhom"].ToString(), hdfRecordID.Text) == false)
                {
                    TieuChi_DotDanhGiaInfo info = new TieuChi_DotDanhGiaInfo()
                    {
                        MaDotDanhGia = hdfRecordID.Text,
                        MaTieuChi    = emp.Rows[0]["MaNhom"].ToString(),
                        CreatedDate  = DateTime.Now,
                        CreatedBy    = CurrentUser.ID
                    };
                    int id = new TieuChi_DotDanhGiaController().Insert(info);
                    info.ID = id;

                    // tạo bản đánh giá trống
                    //CreateKetQuaDanhGiaByIdTieuChiDotDanhGia(info);
                }
                else
                {
                    str += emp.Rows[0]["TenNhom"].ToString() + ", ";
                }
            }
        }
        RM.RegisterClientScriptBlock("reloadst2", "#{grp_DanhSachTieuChi_Store}.reload();");
        if (!string.IsNullOrEmpty(str))
        {
            X.MessageBox.Alert("Thông báo", "Các tiêu chí sau đã tồn tại: " + str).Show();
        }
        else
        {
            X.MessageBox.Alert("Thông báo", "Đã thêm cán bộ thành công");
        }
        wdThemTieuChiDanhGia.Hide();
    }
    private void CreateKetQuaDanhGiaByIdTieuChiDotDanhGia(TieuChi_DotDanhGiaInfo tcd)
    {
        DataTable canbos = new CanBoDuocDanhGiaController().GetByMaDotDanhGia(tcd.MaDotDanhGia);

        foreach (DataRow item in canbos.Rows)
        {
            DAL.KetQuaDanhGia tmp = new KetQuaDanhGiaController().GetByMaCBvaIdTieuChiDotDanhGia(item["MaCB"].ToString(), tcd.ID);
            if (tmp == null)
            {
                DAL.KetQuaDanhGia info = new DAL.KetQuaDanhGia()
                {
                    CreatedBy            = CurrentUser.ID,
                    CreatedDate          = DateTime.Now,
                    Diem                 = 0,
                    IdTieuChi_DotDanhGia = tcd.ID,
                    IsQuanLyDanhGia      = false,
                    MaCB                 = item["MaCB"].ToString(),
                    NhanXet              = ""
                };
                new KetQuaDanhGiaController().Insert(info);
            }
        }
    }
    protected void btnOK_Click(object sender, DirectEventArgs e)
    {
        try
        {
            DAL.DotDanhGia record = new DotDanhGiaController().GetByPrkey(txtmaloaihdcoppy.Text);
            if (record != null)
            {
                Dialog.ShowNotification("Mã đã tồn tại");
            }
            else
            {
                record = new DotDanhGiaController().GetByPrkey(hdfRecordID.Text);
                DAL.DotDanhGia item = new DAL.DotDanhGia()
                {
                    ID                  = txtmaloaihdcoppy.Text,
                    TenDotDanhGia       = txtTenDotMoi.Text,
                    TuNgay              = record.TuNgay,
                    DenNgay             = record.DenNgay,
                    TrangThaiDanhGia    = record.TrangThaiDanhGia,
                    GhiChu              = record.GhiChu,
                    CreatedBy           = CurrentUser.ID,
                    CreatedDate         = DateTime.Now,
                    MaDonVi             = record.MaDonVi,
                    HinhThucDanhGia     = record.HinhThucDanhGia,
                    TL_TuDanhGia        = record.TL_TuDanhGia,
                    TL_QuanLyDanhGia    = record.TL_QuanLyDanhGia,
                    TL_NguoiKhacDanhGia = record.TL_NguoiKhacDanhGia,
                    MaLoaiXepHang       = record.MaLoaiXepHang,
                    PrkeyCanBoQuanLy    = record.PrkeyCanBoQuanLy
                };
                new DotDanhGiaController().Insert(item);

                #region nhân đôi dữ liệu cán bộ bị đánh giá
                if (chkBiDanhGia.Checked || record.HinhThucDanhGia == 0 || record.HinhThucDanhGia == 1)
                {
                    var table = new CanBoDuocDanhGiaController().GetByMaDotDanhGia(hdfRecordID.Text);
                    foreach (DataRow it in table.Rows)
                    {
                        CanBoDuocDanhGiaInfo info = new CanBoDuocDanhGiaInfo()
                        {
                            MaCB         = it["MaCB"].ToString(),
                            MaDotDanhGia = txtmaloaihdcoppy.Text,
                            CreatedBy    = CurrentUser.ID,
                            CreatedDate  = DateTime.Now
                        };
                        new CanBoDuocDanhGiaController().Insert(info);
                    }
                }
                #endregion

                #region nhân đôi dữ liệu cán bộ tham gia đánh giá
                if (chkThamGiaDanhGia.Checked || record.HinhThucDanhGia == 0 || record.HinhThucDanhGia == 1)
                {
                    var table = new CanBoThamGiaDanhGiaController().GetByMaDotDanhGia(hdfRecordID.Text);
                    foreach (DataRow it in table.Rows)
                    {
                        CanBoThamGiaDanhGiaInfo info = new CanBoThamGiaDanhGiaInfo()
                        {
                            MaCBBiDanhGia = it["MaCBBiDanhGia"].ToString(),
                            MaCBDanhGia   = it["MaCBDanhGia"].ToString(),
                            MaDotDanhGia  = txtmaloaihdcoppy.Text,
                            CreatedBy     = CurrentUser.ID,
                            CreatedDate   = DateTime.Now
                        };
                        new CanBoThamGiaDanhGiaController().Insert(info);
                    }
                }
                #endregion

                #region nhân đôi dữ liệu tiêu chí đánh giá
                if (chkTieuChiDanhGia.Checked)
                {
                    var table = new TieuChi_DotDanhGiaController().GetByMaDotDanhGia(hdfRecordID.Text);
                    foreach (DataRow it in table.Rows)
                    {
                        TieuChi_DotDanhGiaInfo info = new TieuChi_DotDanhGiaInfo()
                        {
                            MaDotDanhGia = txtmaloaihdcoppy.Text,
                            MaTieuChi    = it["MaTieuChi"].ToString(),
                            CreatedDate  = DateTime.Now,
                            CreatedBy    = CurrentUser.ID
                        };
                        new TieuChi_DotDanhGiaController().Insert(info);
                    }
                }
                #endregion

                GridPanel1.Reload();
            }
            wdInputNewPrimaryKey.Hide();
        }
        catch (Exception ex)
        {
            Dialog.ShowError(ex.Message.ToString());
        }
    }
 public int Insert(TieuChi_DotDanhGiaInfo record)
 {
     return(int.Parse(DataController.DataHandler.GetInstance().ExecuteScalar("InsertTieuChi_DotDanhGia", "@MaTieuChi", "@MaDotDanhGia", "@CreatedDate", "@CreatedBy", record.MaTieuChi, record.MaDotDanhGia, record.CreatedDate, record.CreatedBy).ToString()));
 }