Esempio n. 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string sql;
            string tenLop = txtTenLop.Text;

            if (string.IsNullOrEmpty(maLop))
            {
                sql  = "insert into LOP(MaLop, TenLop) values('LP' + cast(next value for giaovienSeq as char(10)),";
                sql += "'" + tenLop + "'";
                sql += ")";
            }
            else
            {
                sql = "update LOP set TenLop = '" + tenLop + "' where MaLop = '" + maLop + "'";
            }
            bool rs = new CSDL().executeNonQuery(sql);

            if (rs)
            {
                if (string.IsNullOrEmpty(maLop))
                {
                    MessageBox.Show("Thêm mới thành công");
                }
                else
                {
                    MessageBox.Show("Cập nhật thành công");
                }
                this.Dispose();
            }
            else
            {
                MessageBox.Show("Thao tác không thành công");
            }
        }
Esempio n. 2
0
 private void btnHSTimKiem_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txbHSThongTin.Text))
     {
         MessageBox.Show("Bạn chưa nhập thông tin tìm kiếm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         if (cbbHSDanhSach.SelectedIndex != -1)
         {
             String valueSearch = txbHSThongTin.Text;
             var    db          = new CSDL();
             String sqlSearch   = "";
             if (cbbHSDanhSach.SelectedIndex == 0)
             {
                 sqlSearch = "exec searchMHS '" + valueSearch + "'";
                 if (db.SelectData(sqlSearch).Rows.Count != 0)
                 {
                     new SearchOut(sqlSearch).Show();
                 }
                 else
                 {
                     MessageBox.Show("Không tìm thấy thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             else if (cbbHSDanhSach.SelectedIndex == 1)
             {
                 sqlSearch = "exec searchTHS N'" + valueSearch + "'";
                 if (db.SelectData(sqlSearch).Rows.Count != 0)
                 {
                     new SearchOut(sqlSearch).Show();
                 }
                 else
                 {
                     MessageBox.Show("Không tìm thấy thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             else if (cbbHSDanhSach.SelectedIndex == 2)
             {
                 sqlSearch = "exec searchHSfromML N'" + valueSearch + "'";
                 if (db.SelectData(sqlSearch).Rows.Count != 0)
                 {
                     new SearchOut(sqlSearch).Show();
                 }
                 else
                 {
                     MessageBox.Show("Không tìm thấy thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
         resetValue();
     }
 }
Esempio n. 3
0
        private void btnLopXoa_Click(object sender, EventArgs e)
        {
            var db = new CSDL();

            if (MessageBox.Show("Bạn muốn xóa lớp " + dgvLop.CurrentRow.Cells["TenLop"].Value.ToString() + " ?", "Warning!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                var tenLop = dgvLop.CurrentRow.Cells["TenLop"].Value.ToString();
                var idLop  = dgvLop.CurrentRow.Cells["MaLop"].Value.ToString();
                db.del_dataLop(idLop);
                MessageBox.Show("Đã xóa lớp : " + tenLop);
            }
            LoadDSLop();
        }
Esempio n. 4
0
        private void btnHSXoa_Click(object sender, EventArgs e)
        {
            var db = new CSDL();

            if (MessageBox.Show("Bạn muốn xóa học sinh " + dgvHocSinh.CurrentRow.Cells["TenHS"].Value.ToString() + " ?", "Warning!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                db.del_dataHS(dgvHocSinh.CurrentRow.Cells["MaHS"].Value.ToString());
            }

            // Hien thi mess thong bao

            LoadHS();
        }
Esempio n. 5
0
        private void btnGVXoa_Click(object sender, EventArgs e)
        {
            var db = new CSDL();

            if (MessageBox.Show("Bạn muốn xóa giáo viên " + dgvGiaoVien.CurrentRow.Cells["TenGV"].Value.ToString() + " ?", "Warning!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                var tenGV = dgvGiaoVien.CurrentRow.Cells["TenGV"].Value.ToString();
                var idGV  = dgvGiaoVien.CurrentRow.Cells["MaGV"].Value.ToString();
                db.del_data(idGV);
                MessageBox.Show("Đã xóa giáo viên : " + tenGV);
            }
            LoadDSGV();
        }
Esempio n. 6
0
        private void btnLopTimKiem_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txbLopThongTin.Text))
            {
                MessageBox.Show("Bạn chưa nhập thông tin tìm kiếm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                if (cbbLopDanhSach.SelectedIndex != -1)
                {
                    string valueSearch = txbLopThongTin.Text;
                    var    db          = new CSDL();
                    string sqlSearch   = "";
                    switch (cbbLopDanhSach.SelectedItem)
                    {
                    case "Mã lớp":
                        sqlSearch = "select MaLop, TenLop from LOP where MaLop = '" + valueSearch + "'";
                        if (db.SelectData(sqlSearch).Rows.Count != 0)
                        {
                            dgvLop.DataSource = new CSDL().SelectData(sqlSearch);

                            dgvLop.Columns["MaLop"].HeaderText  = "Mã Lớp";
                            dgvLop.Columns["TenLop"].HeaderText = "Tên Lớp";
                        }
                        else
                        {
                            MessageBox.Show("Không tìm thấy thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        break;

                    case "Tên lớp":
                        sqlSearch = "select MaLop, TenLop from LOP where TenLop = '" + valueSearch + "'";
                        if (db.SelectData(sqlSearch).Rows.Count != 0)
                        {
                            dgvLop.DataSource = new CSDL().SelectData(sqlSearch);

                            dgvLop.Columns["MaLop"].HeaderText  = "Mã Lớp";
                            dgvLop.Columns["TenLop"].HeaderText = "Tên Lớp";
                        }
                        else
                        {
                            MessageBox.Show("Không tìm thấy thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        break;
                    }
                }
                resetValue();
            }
        }
Esempio n. 7
0
        private void ThemLop_Load(object sender, EventArgs e)
        {
            CSDL csdl = new CSDL();

            if (string.IsNullOrEmpty(maLop))
            {
                this.Text = "Thêm lớp mới";
            }
            else
            {
                this.Text = "Cập nhật thông tin lớp";
                DataRow dr = csdl.Select("select MaLop, TenLop from LOP where MaLop = '" + maLop + "'");
                txtTenLop.Text = dr["TenLop"].ToString();
            }
        }
Esempio n. 8
0
        private void ThemHocSinh_Load(object sender, EventArgs e)
        {
            //MessageBox.Show("Mã SV nhận được: " + msv);
            CSDL      csdl        = new CSDL();
            string    getAllMaLop = "SELECT MaLop FROM LOP";
            DataTable maLopTable  = csdl.SelectData(getAllMaLop);

            cbMaLop.DataSource    = maLopTable.Copy();
            cbMaLop.DisplayMember = "MaLop";
            cbMaLop.ValueMember   = "MaLop";
            if (!string.IsNullOrEmpty(mhs))
            {
                this.Text = "Cập nhật thông tin học sinh";

                var r = new CSDL().Select(string.Format("selectHSById '" + mhs + "'"));
                //MessageBox.Show(r[0].ToString());

                txtTenHS.Text = r["TenHS"].ToString();
                //mtbNS.Text = r["NgaySinh"].ToString();
                dtpBirthday.Value = DateTime.ParseExact(r["NgaySinh"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
                txtDC.Text        = r["DiaChi"].ToString();
                if (r["GioiTinh"].ToString() == "Nam")
                {
                    rbtNam.Checked = true;
                }
                else
                {
                    rbtNu.Checked = true;
                }
                //cbTenNGS.SelectedText = r["TenNGS"].ToString();
                //cbTenPB.SelectedText = r["TenPB"].ToString();
            }
            else
            {
                this.Text = "Thêm mới nhân viên";
            }
        }
Esempio n. 9
0
        private void ThemGiaoVien_Load(object sender, EventArgs e)
        {
            CSDL      csdl        = new CSDL();
            string    getAllMaLop = "SELECT MaLop FROM LOP";
            DataTable maLopTable  = csdl.SelectData(getAllMaLop);

            cbMaLop.DataSource    = maLopTable.Copy();
            cbMaLop.DisplayMember = "MaLop";
            cbMaLop.ValueMember   = "MaLop";
            if (string.IsNullOrEmpty(mgv))
            {
                this.Text = "Thêm mới nhân viên";
            }
            else
            {
                this.Text = "Cập nhật thông tin sinh viên";

                var r = new CSDL().Select(string.Format("selectGVById '" + mgv + "'"));

                txtTenGV.Text     = r["TenGV"].ToString();
                dtpBirthday.Value = DateTime.ParseExact(r["NgaySinh"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
                txtDC.Text        = r["DiaChi"].ToString();
                if (r["GioiTinh"].ToString() == "Nam")
                {
                    rbtNam.Checked = true;
                }
                else
                {
                    rbtNu.Checked = true;
                }
                txtHocVan.Text = r["HocVan"].ToString();
                txtDayMon.Text = r["DayMon"].ToString();
                string maLop = r["MaLop"].ToString();
                cbMaLop.SelectedValue = maLop;
            }
        }
Esempio n. 10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string      sql;
            string      TenHS    = txtTenHS.Text;
            DateTime    NgaySinh = dtpBirthday.Value;
            string      DiaChi   = txtDC.Text;
            string      GioiTinh = rbtNam.Checked ? "Nam" : "Nu";
            DataRowView drvMaLop = (DataRowView)cbMaLop.SelectedItem;
            string      MaLop    = drvMaLop.Row.Field <string>("MaLop");

            List <CustomParameter> lstPara = new List <CustomParameter>();

            if (string.IsNullOrEmpty(mhs))
            {
                sql = "ThemMoiHS";
            }
            else
            {
                sql = "UpdateHS";
                lstPara.Add(new CustomParameter()
                {
                    key   = "@MaHS",
                    value = mhs
                });
            }

            lstPara.Add(new CustomParameter()
            {
                key   = "@TenHS",
                value = TenHS
            });

            lstPara.Add(new CustomParameter()
            {
                key   = "@NS",
                value = NgaySinh.ToString("yyyy-MM-dd")
            });

            lstPara.Add(new CustomParameter()
            {
                key   = "@DC",
                value = DiaChi
            });

            lstPara.Add(new CustomParameter()
            {
                key   = "@GT",
                value = GioiTinh
            });
            lstPara.Add(new CustomParameter()
            {
                key   = "@MaLop",
                value = MaLop
            });


            var rs = new CSDL().ExeCute(sql, lstPara);

            if (rs == 1)
            {
                if (string.IsNullOrEmpty(mhs))
                {
                    MessageBox.Show("Thêm mới thành công");
                }
                else
                {
                    MessageBox.Show("Cập nhật thành công");
                }
                this.Dispose();
            }
            else
            {
                MessageBox.Show("Thao tác không thành công");
            }
        }