Ejemplo n.º 1
0
        protected override void DeleteRow()
        {
            try
            {
                DeleteRowGrid(dgv_DanhSach, "ID", "TenPhong");
                if (IdDelete.Count <= 0) return;
                foreach (var i in IdDelete)
                {
                    var xp = new XepPhong
                    {
                        IdKyThi = _idkythi,
                        IdPhong = i
                    };

                    var ktp = new KTPhong
                    {
                        IdKyThi = _idkythi,
                        IdPhong = i
                    };
                    _listXepPhong.Add(xp);
                    _listKtPhong.Add(ktp);
                }
                DeleteData.XoaKtPhong(_listKtPhong);
                UpdateData.UpdateXepPhongNull(_listXepPhong);
                MessageBox.Show(FormResource.MsgThongbaothanhcong, FormResource.MsgCaption, MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
                LoadGrid();
                IdDelete.Clear();
            }
            catch (Exception ex)
            {
                Log2File.LogExceptionToFile(ex);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// lưu 1 sv được chọn tham gia thi
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool Chonsinhvien(XepPhong item)
 {
     try
     {
         Conn.ExcuteQuerySql("insert into XepPhong(IdSV,IdKyThi) values(" + item.IdSV + "," + item.IdKyThi + ")");
         return true;
     }
     catch (Exception ex)
     {
         Log2File.LogExceptionToFile(ex);
         return false;
     }
 }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cboPhongthi.Text))
            {
                errorPhongthi.SetError(cboPhongthi, "Chọn Phòng thi");
                return;
            }
            if (bUpdate)
            {
                var hs = new XepPhong
                {
                    IdSV = int.Parse(txtmasinhvien.Text),
                    IdPhong = int.Parse(cboPhongthi.Value.ToString()),
                    IdKyThi = IdKythi
                };
                UpdateData.UpdateXepPhong(hs);
                UpdateData.UpdateKtPhong(hs.IdPhong, IdPhong, IdKythi);
                bUpdate = false;
                Close();
            }
            else
            {
                var a = cboPhongthi.Value;
                if (a == null) return;
                var hsxp = new XepPhong
                {
                    IdKyThi = IdKythi,
                    IdPhong = (int)a,
                    IdSV = int.Parse(txtmasinhvien.Text),
                };

                var hspp = new KTPhong
                {
                    IdKyThi = IdKythi,
                    IdPhong = (int)a,
                    SiSo = 1
                };
                UpdateData.UpdateXepPhong(hsxp);
                UpdateData.UpdateTangSiSo(hspp.IdPhong, hspp.IdKyThi);
                bUpdate = true;
                Close();
            }
        }
 protected override void DeleteRow()
 {
     try
     {
         bool xoa = false;
         if (dgv_DanhSach.Selected.Rows.Count > 0)
         {
             if (DialogResult.Yes ==
                 MessageBox.Show(FormResource.msgHoixoa, FormResource.MsgCaption, MessageBoxButtons.YesNo,
                     MessageBoxIcon.Question))
             {
                 foreach (var row in dgv_DanhSach.Selected.Rows)
                 {
                     var masv = row.Cells["MaSV"].Text;
                     var idPhong = row.Cells["IdPhong"].Text;
                     if (!string.IsNullOrEmpty(idPhong))
                     {
                         var ktp = new KTPhong
                         {
                             IdKyThi = _idkythi,
                             IdPhong = int.Parse(idPhong)
                         };
                         _listKtPhong.Add(ktp);
                     }
                     var xp = new XepPhong
                     {
                         IdKyThi = _idkythi,
                         IdSV = int.Parse(masv)
                     };
                     _listXepPhong.Add(xp);
                 }
                 DeleteAndUpdate = true;
                 dgv_DanhSach.DeleteSelectedRows(false);
                 xoa = true;
             }
         }
         else if (dgv_DanhSach.ActiveRow != null)
         {
             if (DialogResult.Yes ==
                 MessageBox.Show(FormResource.msgHoixoa, FormResource.MsgCaption, MessageBoxButtons.YesNo,
                     MessageBoxIcon.Question))
             {
                 var masv = dgv_DanhSach.ActiveRow.Cells["MaSV"].Text;
                 var idPhong = dgv_DanhSach.ActiveRow.Cells["IdPhong"].Text;
                 if (!string.IsNullOrEmpty(idPhong))
                 {
                     var ktp = new KTPhong
                     {
                         IdKyThi = _idkythi,
                         IdPhong = int.Parse(idPhong)
                     };
                     _listKtPhong.Add(ktp);
                 }
                 var xp = new XepPhong
                 {
                     IdKyThi = _idkythi,
                     IdSV = int.Parse(masv)
                 };
                 _listXepPhong.Add(xp);
                 DeleteAndUpdate = true;
                 dgv_DanhSach.ActiveRow.Delete(false);
                 xoa = true;
             }
         }
         UpdateData.UpdateGiamSiSo(_listKtPhong);
         DeleteData.XoaXepPhong(_listXepPhong);
         if (xoa)
         {
             MessageBox.Show(@"Xóa dữ liệu thành công.", @"Thông báo");
         }
         LoadGrid();
     }
     catch (Exception ex)
     {
         Log2File.LogExceptionToFile(ex);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// xóa 1 sinh viên đã được xếp phòng
 /// </summary>
 /// <returns></returns>
 private static void UpdateXP_Null(XepPhong item)
 {
     try
     {
         Conn.ExcuteQuerySql("update XEPPHONG set IdPhong = null where IdSV = " + item.IdSV + " and IdKyThi = " +
                             item.IdKyThi + "");
     }
     catch (Exception ex)
     {
         Log2File.LogExceptionToFile(ex);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// sửa phòng thi cho sinh viên
 /// </summary>
 /// <param name="hs"></param>
 /// <returns></returns>
 public static void UpdateXepPhong(XepPhong hs)
 {
     try
     {
         Conn.ExcuteQuerySql("update XEPPHONG set IdPhong = " + hs.IdPhong + " where IdSV = " + hs.IdSV +
                             " and IdKyThi =" + hs.IdKyThi + "");
     }
     catch (Exception ex)
     {
         Log2File.LogExceptionToFile(ex);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// xóa bảng XEPPHONG theo kỳ thi và mã sinh viên
 /// </summary>
 private static void XoaXepPhong(XepPhong item)
 {
     try
     {
         Conn.ExcuteQuerySql("DELETE FROM XEPPHONG WHERE IdKyThi = " + item.IdKyThi + " and IdSV = " + item.IdSV + "");
     }
     catch (Exception ex)
     {
         Log2File.LogExceptionToFile(ex);
     }
 }