示例#1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMaHV.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập mã học viên", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaHV.Focus();
                return;
            }
            if (txtTenHV.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập tên học viên", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenHV.Focus();
                return;
            }
            if (cboGioitinh.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn giới tính", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtDiem.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập điểm", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiem.Focus();
                return;
            }
            if (txtDiachi.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập địa chỉ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiachi.Focus();
                return;
            }
            if (cboMalop.SelectedIndex == -1)
            {
                MessageBox.Show("mã lớp chưa tồn tại ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboNgay.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn ngày sinh", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboThang.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn tháng sinh", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboNam.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn năm sinh", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboNgay1.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn ngày nộp học phí", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboThang1.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn tháng nộp học phí", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboNam1.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn năm nộp học phí", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboMalop.SelectedIndex == -1)
            {
                MessageBox.Show("mã lớp chưa tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboManghe.SelectedIndex == -1)
            {
                MessageBox.Show("mã nghề chưa tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string sqlCheckkey = "Select * from tblHocvien where MaHocVien = '" + txtMaHV.Text.Trim() + "'";

            DAO.OpenConnection();

            if (DAO.checkKeyexit(sqlCheckkey))
            {
                MessageBox.Show("Mã học viên đã tồn tại");
                DAO.CloseConnection();
                txtMaHV.Focus();
                return;
            }

            else
            {
                string Ngaysinh;
                Ngaysinh = String.Format("{1}/{0}/{2}", cboNgay.Text, cboThang.Text, cboNam.Text);
                string NgayNopHocPhi;
                NgayNopHocPhi = String.Format("{1}/{0}/{2}", cboNgay1.Text, cboThang1.Text, cboNam1.Text);

                string sql = "insert into tblHocvien values('" + txtMaHV.Text.Trim() + "',N'" + txtTenHV.Text.Trim()
                             + "','" + cboMalop.SelectedValue.ToString() + "','" + Ngaysinh + "',N'" + cboGioitinh.Text.Trim()
                             + "',N'" + txtDiachi.Text.Trim() + "','" + cboManghe.SelectedValue.ToString()

                             + "','" + txtSDT.Text.Trim() + "','" + NgayNopHocPhi + "','" + txtDiem.Text.Trim() + "')";



                double sl    = Convert.ToDouble(DAO.DocBang("SELECT SiSo FROM tblLophoc WHERE MaLop=N'" + cboMalop.Text + "'").Rows[0][0].ToString());//XEM LẠI BẢNG NL ĐÃ CÓ SL CHƯA
                double slmoi = sl + 1;
                sql = "UPDATE tblLophoc SET SiSo = " + slmoi + " WHERE MaLop = N'" + cboMalop.Text + "'";
                DAO.CapNhatDuLieu(sql);

                SqlCommand cmd = new SqlCommand(sql, DAO.conn);
                cmd.ExecuteNonQuery();
                LoaddatatoGridview();
                filldatatocombo();
                filldatatocombo1();
                DAO.CloseConnection();
            }
        }
示例#2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMalop.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập mã lớp", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMalop.Focus();
                return;
            }
            if (txtTenlop.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập tên lớp", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenlop.Focus();
                return;
            }
            if (cboMamon.SelectedIndex == -1)
            {
                MessageBox.Show("mã môn chưa tồn tại ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboMaGV.SelectedIndex == -1)
            {
                MessageBox.Show("mã giáo viên chưa tồn tại ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                return;
            }

            if (cboMaca.SelectedIndex == -1)
            {
                MessageBox.Show("mã ca chưa tồn tại ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboNgay.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn ngày BĐ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboThang.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn tháng BĐ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboNam.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn Năm BĐ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboNgay1.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn ngày KT", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboThang1.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn tháng KT", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboNam1.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn Năm KT", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboMathoigian.SelectedIndex == -1)
            {
                MessageBox.Show("mã thời gian chưa tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboMaphong.SelectedIndex == -1)
            {
                MessageBox.Show("mã phòng chưa tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string sqlCheckkey = "Select * from tblLophoc where MaLop = '" + txtMalop.Text.Trim() + "'";

            DAO.OpenConnection();

            if (DAO.checkKeyexit(sqlCheckkey))
            {
                MessageBox.Show("Mã lớp học đã tồn tại");
                DAO.CloseConnection();
                txtMalop.Focus();
                return;
            }
            else
            {
                string NgayBD;
                NgayBD = String.Format("{1}/{0}/{2}", cboNgay.Text, cboThang.Text, cboNam.Text);
                string NgayKT;
                NgayKT = String.Format("{1}/{0}/{2}", cboNgay1.Text, cboThang1.Text, cboNam1.Text);
                string siso;
                siso = string.Format(txtSiso.Text = DAO.GetFieldValues("select count(MaHocVien) from tblHocvien  where Malop ='" + txtMalop.Text + "'"));



                string sql = "insert into tblLophoc values('" + txtMalop.Text.Trim() + "',N'" + txtTenlop.Text.Trim() + "',N'" + cboMamon.Text.Trim() + "',N'" + cboMaGV.Text.Trim()
                             + "','" + NgayBD + "','" + NgayKT
                             + "',N'" + cboMaca.Text.Trim() + "',N'" + cboMathoigian.Text.Trim() + "','" + cboMaphong.Text.Trim()
                             + "','" + siso + "')";

                SqlCommand cmd = new SqlCommand(sql, DAO.conn);


                cmd.ExecuteNonQuery();
                LoaddatatoGridview();
                filldatatocombo();
                filldatatocombo1();
                filldatatocombo2();
                filldatatocombo3();

                DAO.CloseConnection();
            }
        }
示例#3
0
 private void FrmPhonghoc_Load(object sender, EventArgs e)
 {
     DAO.OpenConnection();
     LoaddatatoGridview();
     DAO.CloseConnection();
 }
示例#4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMaGV.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập mã giáo viên", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaGV.Focus();
                return;
            }
            if (txtTenGV.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập tên giáo viên", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenGV.Focus();
                return;
            }
            if (cboGioitinh.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn giới tính", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtSDT.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập điểm", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSDT.Focus();
                return;
            }
            if (txtDiachi.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập địa chỉ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiachi.Focus();
                return;
            }
            if (cboMachucdanh.SelectedIndex == -1)
            {
                MessageBox.Show("mã chức danh chưa tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboNgay.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn ngày sinh", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboThang.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn tháng sinh", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboNam.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn Năm sinh", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboMachuyenmon.SelectedIndex == -1)
            {
                MessageBox.Show("mã chuyên môn chưa tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboMaCQ.SelectedIndex == -1)
            {
                MessageBox.Show("mã cơ quan chưa tồn tại ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cboMatrinhdo.SelectedIndex == -1)
            {
                MessageBox.Show("mã trình độ chưa tồn tại ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string sqlCheckkey = "Select * from tblGiaovien where MaGV = '" + txtMaGV.Text.Trim() + "'";

            DAO.OpenConnection();

            if (DAO.checkKeyexit(sqlCheckkey))
            {
                MessageBox.Show("Mã giáo viên đã tồn tại");
                DAO.CloseConnection();
                txtMaGV.Focus();
                return;
            }
            else
            {
                string Ngaysinh;
                Ngaysinh = String.Format("{1}/{0}/{2}", cboNgay.Text, cboThang.Text, cboNam.Text);



                string sql = "insert into tblGiaovien values('" + txtMaGV.Text.Trim() + "',N'" + txtTenGV.Text.Trim() + "','" + Ngaysinh
                             + "',N'" + cboGioitinh.Text.Trim() + "',N'" + txtDiachi.Text.Trim() + "','" + txtSDT.Text.Trim()
                             + "','" + cboMachucdanh.SelectedValue.ToString() + "','" + cboMachuyenmon.SelectedValue.ToString()

                             + "','" + cboMaCQ.Text.Trim() + "','" + cboMatrinhdo.Text.Trim() + "','" + txtAnh.Text.Trim() + "')";

                SqlCommand cmd = new SqlCommand(sql, DAO.conn);
                cmd.ExecuteNonQuery();
                LoaddatatoGridview();
                filldatatocombo();
                filldatatocombo1();
                filldatatocombo2();
                filldatatocombo3();
                DAO.CloseConnection();
            }
        }