Ejemplo n.º 1
0
    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());
        }
    }
Ejemplo n.º 2
0
    protected void btnCapNhat_Click(object sender, DirectEventArgs e)
    {
        DAL.DotDanhGia       obj = new DAL.DotDanhGia();
        DotDanhGiaController ctr = new DotDanhGiaController();
        string isChangeHTDG      = hdfIsChangeHinhThucDanhGia.Text;

        obj.ID = txtID.Text;
        obj.PrkeyCanBoQuanLy = decimal.Parse("0" + hdfMaNguoiQL.Text);
        obj.TenDotDanhGia    = txtTenDotDanhGia.Text;
        if (txtTuNgay.SelectedDate.ToString().Contains("0001") == false)
        {
            obj.TuNgay = txtTuNgay.SelectedDate;
        }
        if (txtDenNgay.SelectedDate.ToString().Contains("0001") == false)
        {
            obj.DenNgay = txtDenNgay.SelectedDate;
        }
        if (cbxTrangThai.Value != null)
        {
            obj.TrangThaiDanhGia = cbxTrangThai.Value.ToString();
        }
        obj.GhiChu      = txtGhiChu.Text;
        obj.CreatedBy   = CurrentUser.ID;
        obj.CreatedDate = DateTime.Now;
        obj.MaDonVi     = Session["MaDonVi"].ToString();
        if (cbxLoaiDanhGia.SelectedItem != null)
        {
            obj.HinhThucDanhGia = int.Parse(cbxLoaiDanhGia.Value.ToString());
        }
        obj.TL_TuDanhGia        = decimal.Parse(txtTuDanhGia.Text.Replace('.', ','));
        obj.TL_QuanLyDanhGia    = decimal.Parse(txtQuanlyDanhGia.Text.Replace('.', ','));
        obj.TL_NguoiKhacDanhGia = decimal.Parse(txtNguoiKhacDanhGia.Text.Replace('.', ','));
        if (cbLoaiXepHang.SelectedItem != null)
        {
            obj.MaLoaiXepHang = int.Parse(cbLoaiXepHang.SelectedItem.Value);
        }

        if (isChangeHTDG == "Yes")
        {
            hdfIsChangeHinhThucDanhGia.Text = "";
            DataTable table = new TieuChi_DotDanhGiaController().GetByMaDotDanhGia(hdfRecordID.Text);
            foreach (DataRow item in table.Rows)
            {
                int idTieuChiDotDanhGia = int.Parse(item["ID"].ToString());
                // Xóa kết quả đánh giá
                new KetQuaDanhGiaController().DeleteByIdTieuChi_DotDanhGia(idTieuChiDotDanhGia);
            }
            // Xóa danh sách cán bộ bị đánh giá
            new CanBoDuocDanhGiaController().DeleteByMaDotDanhGia(hdfRecordID.Text);
            // Xóa danh sách cán bộ tham gia đánh giá
            new CanBoThamGiaDanhGiaController().DeleteByMaDotDanhGia(hdfRecordID.Text);
            // Xóa danh sách các tiêu chí
            new TieuChi_DotDanhGiaController().DeleteByMaDotDanhGia(hdfRecordID.Text);

            // Thêm cán bộ
            InsertCanBo(obj);
        }

        if (e.ExtraParams["Command"] == "Edit")
        {
            obj.ID = hdfRecordID.Text;
            ctr.Update(obj);
            wdAddWindow.Hide();
            GridPanel1.Reload();
        }
        else
        {
            DAL.DotDanhGia tmp = new DotDanhGiaController().GetByPrkey(txtID.Text);
            if (tmp == null)
            {
                ctr.Insert(obj);
                InsertCanBo(obj);
                if (e.ExtraParams["Close"] == "True")
                {
                    wdAddWindow.Hide();
                }
                GridPanel1.Reload();
            }
            else
            {
                Dialog.ShowNotification("Mã đợt đánh giá đã tồn tại");
            }
        }
    }