public bool Update_ThemThongTin(ThemThongTin themThongTin)
        {
            try
            {
                dataAdapter = new SqlDataAdapter("SELECT * FROM THEMTHONGTIN", conn);
                DataRow row = dataTable.Rows.Find(themThongTin.MaDV);

                if (row != null)
                {
                    row["NGAYVAODOAN"]      = themThongTin.NgayVaoDoan;
                    row["NOIVAODOAN"]       = themThongTin.NoiVaoDoan;
                    row["NGAYVAODANG_L1"]   = themThongTin.NgayVaoDangL1;
                    row["NOIVAODANG_L1"]    = themThongTin.NoiVaoDangL1;
                    row["NGAYCHINHTHUC_L1"] = themThongTin.NgayChinhThucL1;
                    row["NOICONGNHAN_L1"]   = themThongTin.NoiVaoDangL1;
                    row["NGUOIGT_L1"]       = themThongTin.NguoiGioiThieuL1;
                }

                comm = new SqlCommandBuilder(dataAdapter);
                dataAdapter.Update(dataTable);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        //Update Thêm thông tin
        private void Update_ThemThongTin(ThemThongTin themThongTin)
        {
            txt_TTT_MaDV.Text       = themThongTin.MaDV;
            txt_TTT_NoiVD.Text      = themThongTin.NoiVaoDoan;
            txt_TTT_NoiVDL1.Text    = themThongTin.NoiVaoDangL1;
            txt_TTT_NoiCT_L1.Text   = themThongTin.NoiCongNhanL1;
            txt_TTT_NguoiGT_L1.Text = themThongTin.NguoiGioiThieuL1;

            txt_TTT_NgayVD.Text   = themThongTin.NgayVaoDoan.ToShortDateString();
            txt_TTT_NgayVDL1.Text = themThongTin.NgayVaoDangL1.ToShortDateString();
            txt_TTT_NgayCTL1.Text = themThongTin.NgayChinhThucL1.ToShortDateString();

            //DateTime ngayVaoDoan = ConvertStringToDate(txt_TTT_NgayVD.Text);
            //DateTime ngayVaoDangL1;
            //DateTime ngayCTL1;

            //if (maDV == "")
            //{
            //    MessageBox.Show("Vui lòng nhập Mã ĐV!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return null;

            //}
            //else
            //{
            //    if (strVDL1 != "")
            //    {
            //        ngayVaoDangL1 = ConvertStringToDate(txt_TTT_NgayVDL1.Text);
            //        if (strCTL1 != "")
            //        {
            //            ngayCTL1 = ConvertStringToDate(txt_TTT_NgayCTL1.Text);
            //            _themThongTin = new ThemThongTin(maDV, ngayVaoDoan, noiVaoDoan, ngayVaoDangL1, noiVaoDangL1, ngayCTL1, noiCTL1, nguoiGTL1, 0);

            //        }
            //        else
            //        {
            //            _themThongTin = new ThemThongTin(maDV, ngayVaoDoan, noiVaoDoan, ngayVaoDangL1, noiVaoDangL1, nguoiGTL1, 1);

            //        }
            //    }
            //    else
            //    {
            //        _themThongTin = new ThemThongTin(maDV, ngayVaoDoan, noiVaoDoan, 2);

            //    }
            //    //_themThongTin = new ThemThongTin(maDV, ngayVaoDoan, noiVaoDoan, ngayVaoDangL1, noiVaoDangL1, ngayCTL1, noiCTL1, nguoiGTL1);
            //return _themThongTin;
            //}
        }
示例#3
0
        // THÊM THÔNG TIN
        public bool Insert_ThemThongTin(ThemThongTin themThongTin)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;


            cmd.Parameters.Add("@MADV", SqlDbType.NVarChar).Value       = themThongTin.MaDV;
            cmd.Parameters.Add("@NGAYVAODOAN", SqlDbType.Date).Value    = themThongTin.NgayVaoDoan;
            cmd.Parameters.Add("@NOIVAODAON", SqlDbType.NVarChar).Value = themThongTin.NoiVaoDoan;

            if (themThongTin.ViTri == 0)
            {
                cmd.CommandText = "SP_INSERT_THEMTHONGTIN_0";
                cmd.Parameters.Add("@NGAYVAODANG_L1", SqlDbType.Date).Value = themThongTin.NgayVaoDangL1;

                cmd.Parameters.Add("@NOIVAODANG_L1", SqlDbType.NVarChar).Value  = themThongTin.NoiVaoDangL1;
                cmd.Parameters.Add("@NGAYCHINHTHUC_L1", SqlDbType.Date).Value   = themThongTin.NgayChinhThucL1;
                cmd.Parameters.Add("@NOICONGNHAN_L1", SqlDbType.NVarChar).Value = themThongTin.NoiCongNhanL1;
                cmd.Parameters.Add("@NGUOIGT_L1", SqlDbType.NVarChar).Value     = themThongTin.NguoiGioiThieuL1;
            }
            else if (themThongTin.ViTri == 1)
            {
                cmd.CommandText = "SP_INSERT_THEMTHONGTIN_1";
                cmd.Parameters.Add("@NGAYVAODANG_L1", SqlDbType.Date).Value = themThongTin.NgayVaoDangL1;

                cmd.Parameters.Add("@NOIVAODANG_L1", SqlDbType.NVarChar).Value = themThongTin.NoiVaoDangL1;
                cmd.Parameters.Add("@NGUOIGT_L1", SqlDbType.NVarChar).Value    = themThongTin.NguoiGioiThieuL1;
            }
            else
            {
                cmd.CommandText = "SP_INSERT_THEMTHONGTIN_2";
            }

            cmd.Connection = _conn;

            try
            {
                _conn.Open();
                cmd.ExecuteNonQuery();

                return(true);
            }
            catch { return(false); }
            finally { _conn.Close(); }
        }
        //Insert Thêm thông tin
        private ThemThongTin Insert_ThemThongTin()
        {
            string maDV         = txt_TTT_MaDV.Text;
            string noiVaoDoan   = txt_TTT_NoiVD.Text;
            string noiVaoDangL1 = txt_TTT_NoiVDL1.Text;
            string noiCTL1      = txt_TTT_NoiCT_L1.Text;
            string nguoiGTL1    = txt_TTT_NguoiGT_L1.Text;

            string strVD   = txt_TTT_NgayVD.Text;
            string strVDL1 = txt_TTT_NgayVDL1.Text;
            string strCTL1 = txt_TTT_NgayCTL1.Text;

            DateTime ngayVaoDoan = ConvertStringToDate(txt_TTT_NgayVD.Text);
            DateTime ngayVaoDangL1;
            DateTime ngayCTL1;

            if (maDV == "")
            {
                MessageBox.Show("Vui lòng nhập Mã ĐV!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
            else
            {
                if (strVDL1 != "")
                {
                    ngayVaoDangL1 = ConvertStringToDate(txt_TTT_NgayVDL1.Text);
                    if (strCTL1 != "")
                    {
                        ngayCTL1      = ConvertStringToDate(txt_TTT_NgayCTL1.Text);
                        _themThongTin = new ThemThongTin(maDV, ngayVaoDoan, noiVaoDoan, ngayVaoDangL1, noiVaoDangL1, ngayCTL1, noiCTL1, nguoiGTL1, 0);
                    }
                    else
                    {
                        _themThongTin = new ThemThongTin(maDV, ngayVaoDoan, noiVaoDoan, ngayVaoDangL1, noiVaoDangL1, nguoiGTL1, 1);
                    }
                }
                else
                {
                    _themThongTin = new ThemThongTin(maDV, ngayVaoDoan, noiVaoDoan, 2);
                }
                //_themThongTin = new ThemThongTin(maDV, ngayVaoDoan, noiVaoDoan, ngayVaoDangL1, noiVaoDangL1, ngayCTL1, noiCTL1, nguoiGTL1);
                return(_themThongTin);
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            switch (_itemValue)
            {
            case 0:
            {
                _thongTin = new ThongTin();

                _thongTin.MaDV        = txtMaDV.Text;
                _thongTin.HoTen       = txtHoten.Text;
                _thongTin.TenKhaiSinh = txtTenKS.Text;
                _thongTin.BiDanh      = txtBidanh.Text;
                _thongTin.GioiTinh    = txtGioitinh.Text;

                _thongTin.NgaySinh = convertStringToDate(txtNgaysinh.Text);
                _thongTin.QueQuan  = txtQuequan.Text;
                _thongTin.DiaChi   = rtxtDiachi.Text;
                _thongTin.SDT      = txtSDT.Text;

                _thongTin.Email   = txtEmail.Text;
                _thongTin.DanToc  = txtDantoc.Text;
                _thongTin.TonGiao = txtTongiao.Text;
                _thongTin.LinkAnh = _linkAnh;

                _frmUpdate = new frmUpdate(_thongTin, 0);
                _frmUpdate.Show();

                break;
            }

            case 1:
            {
                _themThongTin = new ThemThongTin();

                _themThongTin.MaDV          = txt_TTT_MaDV.Text;
                _themThongTin.NgayVaoDoan   = convertStringToDate(txt_TTT_NgayVD.Text);
                _themThongTin.NoiVaoDoan    = txt_TTT_MaDV.Text;
                _themThongTin.NgayVaoDangL1 = convertStringToDate(txt_TTT_NgayVDL1.Text);

                _themThongTin.NoiVaoDangL1     = txt_TTT_MaDV.Text;
                _themThongTin.NgayChinhThucL1  = convertStringToDate(txt_TTT_NgayCTL1.Text);
                _themThongTin.NoiCongNhanL1    = txt_TTT_MaDV.Text;
                _themThongTin.NguoiGioiThieuL1 = txt_TTT_MaDV.Text;

                _frmUpdate = new frmUpdate(_themThongTin, 1);
                _frmUpdate.Show();
                break;
            }

            case 2:
            {
                _trinhDo = new TrinhDo();

                _trinhDo.MaDV      = txt_TD_MaDV.Text;
                _trinhDo.TrinhDoPT = txt_TD_PT.Text;
                _trinhDo.ChuyenMon = txt_TD_Chuyenmon.Text;
                _trinhDo.HocVi     = txt_TD_Hocvi.Text;

                _trinhDo.DTHocVi  = convertStringToDate(txt_TD_CTHV.Text);
                _trinhDo.HocHam   = txt_TD_Hocham.Text;
                _trinhDo.DTHocham = convertStringToDate(txt_TD_CTHH.Text);
                _trinhDo.LyLuanCT = txt_TD_Lyluan.Text;

                _trinhDo.NgoaiNgu = rtxt_TD_NN.Text;

                _frmUpdate = new frmUpdate(_trinhDo, 2);
                _frmUpdate.Show();
                break;
            }

            case 3:
            {
                _quaTrinhCT = new QuaTrinhCongTac();

                _quaTrinhCT.MaDV     = txt_QT_MaDV.Text;
                _quaTrinhCT.MaPB     = txt_QT_MaPB.Text;
                _quaTrinhCT.PhongBan = txt_QT_TenPB.Text;
                _quaTrinhCT.BatDau   = convertStringToDate(txt_QT_Batdau.Text);

                _quaTrinhCT.KetThuc  = convertStringToDate(txt_QT_Ketthuc.Text);
                _quaTrinhCT.CongViec = txt_QT_Congviec.Text;
                _quaTrinhCT.DiaDiem  = txt_QT_Diadiem.Text;
                _quaTrinhCT.ChucVu   = txt_QT_Chucvu.Text;

                _frmUpdate = new frmUpdate(_quaTrinhCT, 3);
                _frmUpdate.Show();
                break;
            }

            case 4:
            {
                _daoTaoBD = new DaoTao_BoiDuong();

                _daoTaoBD.MaDV    = txt_DT_MaDV.Text;
                _daoTaoBD.BatDau  = convertStringToDate(txt_DT_BD.Text);
                _daoTaoBD.KetThuc = convertStringToDate(txt_DT_KT.Text);
                _daoTaoBD.TenLop  = txt_DT_Tenlop.Text;

                _daoTaoBD.HinhThuc = txt_DT_Hinhthuc.Text;
                _daoTaoBD.ChungChi = txt_DT_Chungchi.Text;

                _frmUpdate = new frmUpdate(_daoTaoBD, 4);
                _frmUpdate.Show();
                break;
            }

            case 5:
            {
                _diNuocNgoai = new DiNuocNgoai();

                _diNuocNgoai.MaDV    = txt_DNN_MaDV.Text;
                _diNuocNgoai.BatDau  = convertStringToDate(txt_DNN_BD.Text);
                _diNuocNgoai.KetThuc = convertStringToDate(txt_DNN_KT.Text);
                _diNuocNgoai.NoiDung = rtxt_DNN_ND.Text;
                _diNuocNgoai.DiaDiem = txt_DNN_DD.Text;

                _frmUpdate = new frmUpdate(_diNuocNgoai, 5);
                _frmUpdate.Show();
                break;
            }

            case 6:
            {
                _khenThuong = new KhenThuong();

                _khenThuong.MaDV     = txt_KT_MaDV.Text;
                _khenThuong.ThoiGian = convertStringToDate(txt_KT_TG.Text);
                _khenThuong.HinhThuc = txt_KT_Hinhthuc.Text;
                _khenThuong.CapQD    = txt_KT_CapQD.Text;
                _khenThuong.LyDo     = rtxt_KT_Lydo.Text;

                _frmUpdate = new frmUpdate(_khenThuong, 6);
                _frmUpdate.Show();
                break;
            }

            case 7:
            {
                _kyLuat = new KyLuat();

                _kyLuat.MaDV     = txt_KL_MaDV.Text;
                _kyLuat.ThoiGian = convertStringToDate(txt_KL_TG.Text);
                _kyLuat.HinhThuc = txt_KL_Hinhthuc.Text;
                _kyLuat.CapQD    = txt_KL_CapQD.Text;
                _kyLuat.LyDo     = rtxt_KL_Lydo.Text;

                _frmUpdate = new frmUpdate(_kyLuat, 7);
                _frmUpdate.Show();
                break;
            }

            case 8:
            {
                _giaDinh = new GiaDinh();

                _giaDinh.MaDV    = txt_GD_MaDV.Text;
                _giaDinh.QuanHe  = txt_GD_QH.Text;
                _giaDinh.HoTen   = txt_GD_Hoten.Text;
                _giaDinh.NamSinh = txt_GD_Namsinh.Text;
                _giaDinh.QueQuan = txt_GD_Quequan.Text;
                _giaDinh.DiaChi  = rtxt_GD_Diachi.Text;

                _frmUpdate = new frmUpdate(_giaDinh, 8);
                _frmUpdate.Show();
                break;
            }

            case 9:
            {
                _tuNhanXet = new TuNhanXet();

                _tuNhanXet.MaDV       = txt_TNX_MaDV.Text;
                _tuNhanXet.PhamChat   = txt_TNX_PC.Text;
                _tuNhanXet.DaoDuc     = txt_TNX_DD.Text;
                _tuNhanXet.NangLuc    = txt_TNX_NL.Text;
                _tuNhanXet.QuanHeQC   = txt_TNX_QHQC.Text;
                _tuNhanXet.KhuyetDiem = txt_TNX_KD.Text;

                _frmUpdate = new frmUpdate(_tuNhanXet, 9);
                _frmUpdate.Show();
                break;
            }
            }
        }
 // THÊM THÔNG TIN
 public bool Insert_ThemThongTin(ThemThongTin themThongTin)
 {
     return(dal_Insert.Insert_ThemThongTin(themThongTin));
 }
 // THÊM THÔNG TIN
 public bool Update_ThemThongTin(ThemThongTin themThongTin)
 {
     return(dal_Update.Update_ThemThongTin(themThongTin));
 }
        public frmUpdate(Object obj, int item)
        {
            InitializeComponent();

            gbThongTin.Visible     = false;
            gbThemThongTin.Visible = false;
            gbTrinhdo.Visible      = false;
            gbQuatrinhCT.Visible   = false;
            gbDaoTao.Visible       = false;
            gbDiNN.Visible         = false;
            gbKhenThuong.Visible   = false;
            gbKyluat.Visible       = false;
            gbGiadinh.Visible      = false;
            gbTuNhanXet.Visible    = false;

            switch (item)
            {
            case 0:
                this._thongTin = (ThongTin)obj;
                Update_ThongTin(_thongTin);
                gbThongTin.Visible = true;
                break;

            case 1:
                this._themThongTin = (ThemThongTin)obj;
                Update_ThemThongTin(_themThongTin);
                gbThemThongTin.Visible = true;
                break;

            case 2:
                this._trinhDo = (TrinhDo)obj;
                Update_TrinhDo(_trinhDo);
                gbTrinhdo.Visible = true;
                break;

            case 3:
                this._quaTrinhCT = (QuaTrinhCongTac)obj;
                Update_QTCT(_quaTrinhCT);
                gbQuatrinhCT.Visible = true;
                break;

            case 4:
                this._daoTaoBD = (DaoTao_BoiDuong)obj;
                Update_DTBD(_daoTaoBD);
                gbDaoTao.Visible = true;
                break;

            case 5:
                this._diNuocNgoai = (DiNuocNgoai)obj;
                Update_DNN(_diNuocNgoai);
                gbDiNN.Visible = true;
                break;

            case 6:
                this._khenThuong = (KhenThuong)obj;
                Update_KT(_khenThuong);
                gbKhenThuong.Visible = true;
                break;

            case 7:
                this._kyLuat = (KyLuat)obj;
                Update_KL(_kyLuat);
                gbKyluat.Visible = true;
                break;

            case 8:
                this._giaDinh = (GiaDinh)obj;
                Update_GD(_giaDinh);
                gbGiadinh.Visible = true;
                break;

            case 9:
                this._tuNhanXet = (TuNhanXet)obj;
                Update_TNX(_tuNhanXet);
                gbTuNhanXet.Visible = true;
                break;
            }
        }