Пример #1
0
        private void btnSuaCV_Click(object sender, EventArgs e)
        {
            ChucVu temp = new ChucVu(txtMaCV.Text, txtTenCV.Text);

            ConnectDatabase.SuaChucVu(temp);
            dgvCV.DataSource = ConnectDatabase.getAllChucVu();
        }
Пример #2
0
        private void btnXoaCV_Click(object sender, EventArgs e)
        {
            ChucVu temp = new ChucVu(txtMaCV.Text, txtTenCV.Text);

            ConnectDatabase.XoaChucVu(temp);
            dgvCV.DataSource = ConnectDatabase.getAllChucVu();
            MessageBox.Show("Xóa Thành Công Chức Vụ!!!");
        }
Пример #3
0
        private void btnSuaCV_Click(object sender, EventArgs e)
        {
            ChucVu temp = new ChucVu(txtTenCV.Text, txtMaCV.Text);

            ConnectDatabase.SuaChucVu(temp);
            dgvCV.DataSource = ConnectDatabase.getAllChucVu();
            MessageBox.Show("Sửa chức vụ thành công!!");
        }
        private void btnThemCV_Click_2(object sender, EventArgs e)
        {
            ChucVu temp = new ChucVu(txtMCV.Text, txtTCV.Text);

            ConnectDatabase.ThemChucVu(temp);

            dgvThemCV.DataSource = ConnectDatabase.getAllChucVu();
        }
        public static void XoaChucVu(ChucVu cv)
        {
            string sql = "DELETE FROM CHUCVU  where MaCV=@macv";

            using (SqlCommand command = new SqlCommand(sql, conn))
            {
                command.Parameters.Add(new SqlParameter("@macv", cv.Macv));
                command.ExecuteNonQuery();
                command.Cancel();
            }
        }
        public static void SuaLuong_PhongBan(Luong l, ChucVu cv, NhanVien nv)
        {
            //string sql = "UPDATE LUONG set Luong = @luong, LuongThuong=@luongthuong, GhiChu=@ghichu where MaNV=@manv";

            //using (SqlCommand command = new SqlCommand(sql, conn))
            //{
            //    command.Parameters.Add(new SqlParameter("@tencv", cv.Tencv));
            //    command.Parameters.Add(new SqlParameter("@macv", cv.Macv));
            //    command.ExecuteNonQuery();
            //    command.Cancel();
            //}
        }
        public static void SuaChucVu(ChucVu cv)
        {
            string sql = "UPDATE CHUCVU set TenCV=@tencv where MaCV=@macv";

            using (SqlCommand command = new SqlCommand(sql, conn))
            {
                command.Parameters.Add(new SqlParameter("@tencv", cv.Tencv));
                command.Parameters.Add(new SqlParameter("@macv", cv.Macv));
                command.ExecuteNonQuery();
                command.Cancel();
            }
        }
        private void btnThemCV_Click_2(object sender, EventArgs e)
        {
            ChucVu temp = new ChucVu(txtMCV.Text, txtTCV.Text);

            if (ConnectDatabase.checkPhongBan(temp.Macv) == 1)
            {
                MessageBox.Show("Mã chức vụ đã tồn tại. Xin mời nhập lại!!!");
                return;
            }
            ConnectDatabase.ThemChucVu(temp);
            dgvThemCV.DataSource = ConnectDatabase.getAllChucVu();
            load();
        }
        public static void ThemChucVu(ChucVu chucvu)
        {
            string     sql = "insert into CHUCVU(MaCV, TenCV) values(@macv, @tencv)";
            SqlCommand cmd = new SqlCommand(sql, conn);

            using (SqlCommand command = new SqlCommand(sql, conn))
            {
                command.Parameters.Add(new SqlParameter("@macv", chucvu.Macv));
                command.Parameters.Add(new SqlParameter("@tencv", chucvu.Tencv));


                int kq = command.ExecuteNonQuery();
                if (kq > 0)
                {
                    MessageBox.Show("Thêm chức vụ mới thành công!");
                }
                else
                {
                    MessageBox.Show("Thêm chức vụ mới thất bại!");
                }
                command.Cancel();
            }
        }