Example #1
0
        private void btnDangky_Click(object sender, EventArgs e)
        {
            this.Hide();
            Dangky dangky = new Dangky();

            dangky.Visible = true;
        }
Example #2
0
        public ActionResult DeleteConfirmed(string id)
        {
            Dangky dangky = db.Dangkys.Find(id);

            db.Dangkys.Remove(dangky);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
 public ActionResult Edit([Bind(Include = "Email,UserName,Password,RoleID")] Dangky dangky)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dangky).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RoleID = new SelectList(db.Roles, "RoleID", "RoleName", dangky.RoleID);
     return(View(dangky));
 }
Example #4
0
        public ActionResult Create([Bind(Include = "Email,UserName,Password,RoleID")] Dangky dangky)
        {
            if (ModelState.IsValid)
            {
                dangky.Password = GetMD5(dangky.Password);
                db.Configuration.ValidateOnSaveEnabled = false;
                db.Dangkys.Add(dangky);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RoleID = new SelectList(db.Roles, "RoleID", "RoleName", dangky.RoleID);
            return(View(dangky));
        }
Example #5
0
        // GET: Dangkies/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dangky dangky = db.Dangkys.Find(id);

            if (dangky == null)
            {
                return(HttpNotFound());
            }
            return(View(dangky));
        }
Example #6
0
        // GET: Dangkies/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dangky dangky = db.Dangkys.Find(id);

            if (dangky == null)
            {
                return(HttpNotFound());
            }
            ViewBag.RoleID = new SelectList(db.Roles, "RoleID", "RoleName", dangky.RoleID);
            return(View(dangky));
        }
Example #7
0
 public ActionResult Register(Dangky _user)
 {
     if (ModelState.IsValid)
     {
         var check = _db.Dangkys.FirstOrDefault(s => s.UserName == _user.UserName);
         if (check == null)
         {
             _user.Password = GetMD5(_user.Password);
             _db.Configuration.ValidateOnSaveEnabled = false;
             _db.Dangkys.Add(_user);
             _db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else
         {
             ViewBag.error = "Email already exists";
             return(View());
         }
     }
     return(View());
 }
        private void button2_Click(object sender, EventArgs e)
        {
            Dangky dk = new Dangky();

            dk.Show();
        }
Example #9
0
        private void btnDangky_Click(object sender, EventArgs e)
        {
            Dangky Dk = new Dangky();

            Dk.ShowDialog();
        }
Example #10
0
        private void btnThiThu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Program.mMalop  = txtMaLop.Text;
            Program.ngayThi = dtNgaythi.Text;

            string malop = Program.mMalop.Trim();

            Program.maMH = txtMaMH.Text;
            string mamh        = Program.maMH;
            string trinhdo     = "";
            int    socauthi    = -1;
            int    thoigianthi = -1;
            string manv        = "";

            Program.KetNoi();
            string        query = "EXEC SP_GET_DK_THI '" + malop + "','" + Program.maMH + "','" + Program.ngayThi + "'";
            SqlDataReader dkthi = Program.ExecSqlDataReader(query);

            if (dkthi == null)
            {
                MessageBox.Show("Đợt thi này không tồn tại trong hệ thống");
            }
            else
            {
                bool c = dkthi.Read();
                if (c == false)
                {
                    MessageBox.Show("Đợt thi này đã không còn tồn tại trong hệ thống! ");
                    return;
                }
                trinhdo      = dkthi.GetString(4).Trim();
                socauthi     = dkthi.GetInt32(6);
                thoigianthi  = dkthi.GetInt32(5);
                manv         = dkthi.GetString(3);
                Program.iddk = dkthi.GetInt32(7);
                Dangky dk = new Dangky(
                    mamh,                            //mamon
                    malop,                           //malop
                    DateTime.Parse(Program.ngayThi), //ngaythi
                    manv,                            //manv
                    trinhdo,
                    thoigianthi,
                    socauthi
                    );
                dkthi.Close();
                DataTable db         = Program.ExecSqlDataTable("EXEC SP_GET_DE_THI '" + Program.maMH + "','" + trinhdo + "'," + socauthi + "");
                int       checkCount = db.Rows.Count;
                if (checkCount == 0)
                {
                    MessageBox.Show("Số câu hỏi thi trong hệ thống không đáp ứng đủ để thi!");
                }
                else
                {
                    Dangky.dangky = dk;
                    this.Close();
                    List <BoDe> list = convertToListBD(db);
                    BoDe.boDe = list;
                    ThiThu form = new ThiThu();
                    form.ShowDialog();
                }
            }
        }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string phong = "";

            if (glueDoitac.Text == "")
            {
                MessageBox.Show("Vui lòng chọn khách hàng hoặc đối tác!");
                glueDoitac.Focus();
                return;
            }
            else
            {
                var idkhach = Convert.ToInt32(glueDoitac.EditValue);
                if (t == 1)
                {
                    if (txtSo.Text == "")
                    {
                        if (gcDangky.DataSource == null)
                        {
                            MessageBox.Show("Vui lòng chọn phòng để đăng ký");
                            return;
                        }
                        Dangky dk = new Dangky();
                        dk.NgayDK       = Convert.ToDateTime(dateNgay.EditValue.ToString());
                        dk.NgayCheckin  = Convert.ToDateTime(dateCheckin.EditValue.ToString());
                        dk.NgayCheckout = Convert.ToDateTime(dateCheckout.EditValue.ToString());
                        dk.SotienUT     = Convert.ToDouble(tbDattruoc.Text.ToString());
                        dk.Sokhach      = Convert.ToInt32(gvDangky.Columns[2].SummaryItem.SummaryValue);
                        dk.Sophong      = Convert.ToInt32(gvDangky.Columns[3].SummaryItem.SummaryValue);
                        dk.DaCheckin    = false;
                        dk.Ghichu       = tbNoidung.Text.ToString();
                        dk.HinhthucTT   = cbHinhthuc.EditValue.ToString();
                        dk.Loaitien     = cbxLoai.EditValue.ToString();
                        if (dk.HinhthucTT == "Tiền mặt")
                        {
                            dk.SoATM = "";
                        }
                        else
                        {
                            dk.SoATM = tbSoTK.EditValue.ToString();
                        }
                        dk.Tygia  = Convert.ToInt32(tbTygia.Text.ToString());
                        dk.MaBank = glueNganhang.EditValue.ToString();
                        dk.NgayUT = Convert.ToDateTime(dtDattruoc.EditValue.ToString());
                        db.Dangky.Add(dk);
                        db.SaveChanges();
                        var id = db.Dangky.Where(m => m.DaCheckin == false).OrderByDescending(m => m.Id).First();
                        for (int j = 0; j < gvDangky.RowCount; j++)
                        {
                            GridView dView = gvDangky.GetDetailView(j, 0) as GridView;
                            if (dView == null)
                            {
                                MessageBox.Show("Vui lòng nhập thông tin khách hàng đăng ký!");
                                return;
                            }
                            phong.Trim();
                            phong += gvDangky.GetRowCellValue(j, gvDangky.Columns[0]).ToString();
                            if (j < gvDangky.RowCount - 1)
                            {
                                phong += ",";
                            }
                            DK_Customer dk_khach = new DK_Customer();
                            Khach       khach    = new Khach();
                            DangKyPhong dk_phong = new DangKyPhong();
                            for (int i = 0; i < dView.RowCount; i++)
                            {
                                if (dView.GetRowCellValue(i, dView.Columns[0]) != null && dView.GetRowCellValue(i, dView.Columns[1]) != null)
                                {
                                    khach.HoTen    = dView.GetRowCellValue(i, dView.Columns[1]).ToString();
                                    khach.SoCMND   = dView.GetRowCellValue(i, dView.Columns[0]).ToString();
                                    khach.GioiTnh  = Convert.ToBoolean(dView.GetRowCellValue(i, dView.Columns[2]));
                                    khach.MaQT     = Convert.ToInt32(dView.GetRowCellValue(i, dView.Columns[3]));
                                    khach.NgaySinh = DateTime.Now;
                                    khach.DonVi    = "Khách hàng";
                                    if (edtDienThoai.Text == "Nhập số điện thoại")
                                    {
                                        khach.Phone = "";
                                    }
                                    else
                                    {
                                        khach.Phone = edtDienThoai.Text.ToString();
                                    }
                                    db.Khach.Add(khach);
                                    db.SaveChanges();
                                    var idkh = db.Khach.OrderByDescending(m => m.Id).First();
                                    dk_khach.IdDK         = id.Id;
                                    dk_khach.IdKH         = idkhach;
                                    dk_khach.Hoten        = dView.GetRowCellValue(i, dView.Columns[1]).ToString();
                                    dk_khach.CMND         = dView.GetRowCellValue(i, dView.Columns[0]).ToString();
                                    dk_khach.Gioitinh     = Convert.ToBoolean(dView.GetRowCellValue(i, dView.Columns[2]));
                                    dk_khach.Quoctich     = Convert.ToInt32(dView.GetRowCellValue(i, dView.Columns[3]));
                                    dk_khach.Sophong      = Convert.ToInt32(gvDangky.GetRowCellValue(j, gvDangky.Columns[0]));
                                    dk_khach.DateCheckin  = Convert.ToDateTime(dateCheckin.EditValue.ToString());
                                    dk_khach.DateCheckout = Convert.ToDateTime(dateCheckout.EditValue.ToString());
                                    dk_khach.GioCheckin   = DateTime.Now.ToShortTimeString();
                                    dk_khach.GioCheckout  = "12:00";
                                    db.DK_Customers.Add(dk_khach);
                                    db.SaveChanges();
                                    dk_phong.IDDK         = id.Id;
                                    dk_phong.SoPhong      = Convert.ToInt32(gvDangky.GetRowCellValue(j, gvDangky.Columns[0]));
                                    dk_phong.NgayCheckIn  = Convert.ToDateTime(dateCheckin.EditValue.ToString());
                                    dk_phong.NgayCheckOut = Convert.ToDateTime(dateCheckout.EditValue.ToString());
                                    dk_phong.LoaiTien     = id.Loaitien;
                                    dk_phong.TyGia        = id.Tygia;
                                    dk_phong.GhiChu       = id.Ghichu;
                                    dk_phong.DaCheckIn    = id.DaCheckin;
                                    dk_phong.DonGia       = Convert.ToInt32(gvDangky.GetRowCellValue(j, gvDangky.Columns[1]));
                                    db.DangKyPhong.Add(dk_phong);
                                }
                            }
                        }
                        txtSo.Text = id.ToString();
                        var update = db.Dangky.FirstOrDefault(m => m.Id == id.Id);
                        update.Phong = phong.ToString();
                        db.SaveChanges();
                        t = 0;
                    }
                    else
                    {
                        var id = Convert.ToInt32(txtSo.Text);
                        var dk = db.Dangky.FirstOrDefault(m => m.Id == id);
                        dk.NgayDK       = Convert.ToDateTime(dateNgay.EditValue.ToString());
                        dk.NgayCheckin  = Convert.ToDateTime(dateCheckin.EditValue.ToString());
                        dk.NgayCheckout = Convert.ToDateTime(dateCheckout.EditValue.ToString());
                        dk.SotienUT     = Convert.ToDouble(tbDattruoc.Text.ToString());
                        dk.Sokhach      = Convert.ToInt32(gvDangky.Columns[2].SummaryItem.SummaryValue);
                        dk.Sophong      = Convert.ToInt32(gvDangky.Columns[3].SummaryItem.SummaryValue);
                        dk.DaCheckin    = false;
                        dk.Ghichu       = tbNoidung.Text.ToString();
                        dk.HinhthucTT   = cbHinhthuc.EditValue.ToString();
                        dk.Loaitien     = cbxLoai.EditValue.ToString();
                        if (dk.HinhthucTT == "Tiền mặt")
                        {
                            dk.SoATM = "";
                        }
                        else
                        {
                            dk.SoATM = tbSoTK.EditValue.ToString();
                        }
                        dk.Tygia  = Convert.ToInt32(tbTygia.Text.ToString());
                        dk.MaBank = glueNganhang.EditValue.ToString();
                        dk.NgayUT = Convert.ToDateTime(dtDattruoc.EditValue.ToString());
                        phong     = dk.Phong.ToString();
                        db.SaveChanges();
                        var dkphong = db.DangKyPhong.Where(m => m.IDDK == id).Count();
                        if (gvDangky.RowCount > dkphong)
                        {
                            for (int j = dkphong; j < gvDangky.RowCount; j++)
                            {
                                GridView dView = gvDangky.GetDetailView(j, 0) as GridView;
                                phong.Trim();
                                phong += gvDangky.GetRowCellValue(j, gvDangky.Columns[0]).ToString();
                                if (j < gvDangky.RowCount - 1)
                                {
                                    phong += ",";
                                }
                                DK_Customer dk_khach = new DK_Customer();
                                Khach       khach    = new Khach();
                                DangKyPhong dk_phong = new DangKyPhong();
                                for (int i = 0; i < dView.RowCount; i++)
                                {
                                    if (dView.GetRowCellValue(i, dView.Columns[0]) != null && dView.GetRowCellValue(i, dView.Columns[1]) != null)
                                    {
                                        khach.HoTen    = dView.GetRowCellValue(i, dView.Columns[1]).ToString();
                                        khach.SoCMND   = dView.GetRowCellValue(i, dView.Columns[0]).ToString();
                                        khach.GioiTnh  = Convert.ToBoolean(dView.GetRowCellValue(i, dView.Columns[2]));
                                        khach.MaQT     = Convert.ToInt32(dView.GetRowCellValue(i, dView.Columns[3]));
                                        khach.NgaySinh = DateTime.Now;
                                        khach.DonVi    = "Khách hàng";
                                        if (edtDienThoai.Text == "Nhập số điện thoại")
                                        {
                                            khach.Phone = "";
                                        }
                                        else
                                        {
                                            khach.Phone = edtDienThoai.Text.ToString();
                                        }
                                        db.Khach.Add(khach);
                                        db.SaveChanges();
                                        dk_khach.IdDK         = id;
                                        dk_khach.IdKH         = idkhach;
                                        dk_khach.Hoten        = dView.GetRowCellValue(i, dView.Columns[1]).ToString();
                                        dk_khach.CMND         = dView.GetRowCellValue(i, dView.Columns[0]).ToString();
                                        dk_khach.Gioitinh     = Convert.ToBoolean(dView.GetRowCellValue(i, dView.Columns[2]));
                                        dk_khach.Quoctich     = Convert.ToInt32(dView.GetRowCellValue(i, dView.Columns[3]));
                                        dk_khach.Sophong      = Convert.ToInt32(gvDangky.GetRowCellValue(j, gvDangky.Columns[0]));
                                        dk_khach.DateCheckin  = Convert.ToDateTime(dateCheckin.EditValue.ToString());
                                        dk_khach.DateCheckout = Convert.ToDateTime(dateCheckout.EditValue.ToString());
                                        dk_khach.GioCheckin   = DateTime.Now.ToShortTimeString();
                                        dk_khach.GioCheckout  = "12:00";
                                        db.DK_Customers.Add(dk_khach);
                                        db.SaveChanges();
                                        dk_phong.IDDK         = id;
                                        dk_phong.SoPhong      = Convert.ToInt32(gvDangky.GetRowCellValue(j, gvDangky.Columns[0]));
                                        dk_phong.NgayCheckIn  = Convert.ToDateTime(dateCheckin.EditValue.ToString());
                                        dk_phong.NgayCheckOut = Convert.ToDateTime(dateCheckout.EditValue.ToString());
                                        dk_phong.LoaiTien     = cbxLoai.EditValue.ToString();
                                        dk_phong.TyGia        = Convert.ToInt32(tbTygia.Text.ToString());
                                        dk_phong.GhiChu       = tbNoidung.Text.ToString();
                                        dk_phong.DaCheckIn    = false;
                                        dk_phong.DonGia       = Convert.ToInt32(gvDangky.GetRowCellValue(j, gvDangky.Columns[1]));
                                        db.DangKyPhong.Add(dk_phong);
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int j = 0; j < gvDangky.RowCount; j++)
                            {
                                var         sophong  = Convert.ToInt32(gvDangky.GetRowCellValue(j, gvDangky.Columns[0]));
                                var         dkkhach  = db.DK_Customers.Where(m => m.IdDK == id && m.Sophong == sophong).Count();
                                GridView    dView    = gvDangky.GetDetailView(j, 0) as GridView;
                                DK_Customer dk_khach = new DK_Customer();
                                Khach       khach    = new Khach();
                                DangKyPhong dk_phong = new DangKyPhong();
                                int         dem      = 0;
                                for (int i = 0; i < dView.RowCount; i++)
                                {
                                    if (dView.GetRowCellValue(i, dView.Columns[0]) != null && dView.GetRowCellValue(i, dView.Columns[1]) != null)
                                    {
                                        dem++;
                                    }
                                }
                                if (dem > dkkhach)
                                {
                                    for (int i = dkkhach; i < dView.RowCount; i++)
                                    {
                                        if (dView.GetRowCellValue(i, dView.Columns[0]) != null && dView.GetRowCellValue(i, dView.Columns[1]) != null)
                                        {
                                            khach.HoTen    = dView.GetRowCellValue(i, dView.Columns[1]).ToString();
                                            khach.SoCMND   = dView.GetRowCellValue(i, dView.Columns[0]).ToString();
                                            khach.GioiTnh  = Convert.ToBoolean(dView.GetRowCellValue(i, dView.Columns[2]));
                                            khach.MaQT     = Convert.ToInt32(dView.GetRowCellValue(i, dView.Columns[3]));
                                            khach.NgaySinh = DateTime.Now;
                                            khach.DonVi    = "Khách hàng";
                                            if (edtDienThoai.Text == "Nhập số điện thoại")
                                            {
                                                khach.Phone = "";
                                            }
                                            else
                                            {
                                                khach.Phone = edtDienThoai.Text.ToString();
                                            }
                                            db.Khach.Add(khach);
                                            db.SaveChanges();
                                            var idkh = db.Khach.OrderByDescending(m => m.Id == idkhach).First();
                                            dk_khach.IdDK         = id;
                                            dk_khach.IdKH         = idkhach;
                                            dk_khach.Hoten        = dView.GetRowCellValue(i, dView.Columns[1]).ToString();
                                            dk_khach.CMND         = dView.GetRowCellValue(i, dView.Columns[0]).ToString();
                                            dk_khach.Gioitinh     = Convert.ToBoolean(dView.GetRowCellValue(i, dView.Columns[2]));
                                            dk_khach.Quoctich     = Convert.ToInt32(dView.GetRowCellValue(i, dView.Columns[3]));
                                            dk_khach.Sophong      = Convert.ToInt32(gvDangky.GetRowCellValue(i, gvDangky.Columns[0]));
                                            dk_khach.DateCheckin  = Convert.ToDateTime(dateCheckin.EditValue.ToString());
                                            dk_khach.DateCheckout = Convert.ToDateTime(dateCheckout.EditValue.ToString());
                                            dk_khach.GioCheckin   = DateTime.Now.ToShortTimeString();
                                            dk_khach.Sophong      = Convert.ToInt32(dView.GetRowCellValue(i, dView.Columns[4]));
                                            dk_khach.GioCheckout  = "12:00";
                                            db.DK_Customers.Add(dk_khach);
                                            db.SaveChanges();
                                        }
                                    }
                                }
                                else if (dem <= dkkhach)
                                {
                                    for (int i = 0; i < dkkhach; i++)
                                    {
                                        if (dView.GetRowCellValue(i, dView.Columns[0]) != null && dView.GetRowCellValue(i, dView.Columns[1]) != null)
                                        {
                                            var iddk      = Convert.ToInt32(dView.GetRowCellValue(i, dView.Columns[5]).ToString());
                                            var editkhach = db.Khach.FirstOrDefault(m => m.Id == idkhach);
                                            if (edtDienThoai.Text == "Nhập số điện thoại")
                                            {
                                                editkhach.Phone = "";
                                            }
                                            else
                                            {
                                                editkhach.Phone = edtDienThoai.Text.ToString();
                                            }
                                            db.SaveChanges();
                                            DK_Customer edit_dkkhach = (from dkcus in db.DK_Customers
                                                                        where dkcus.Id == iddk
                                                                        select dkcus).DefaultIfEmpty().Single();
                                            DK_Customer dkcustomer = new DK_Customer();
                                            dkcustomer.IdKH           = idkhach;
                                            dkcustomer.Hoten          = dView.GetRowCellValue(i, dView.Columns[1]).ToString();
                                            dkcustomer.CMND           = dView.GetRowCellValue(i, dView.Columns[0]).ToString();
                                            dkcustomer.Gioitinh       = Convert.ToBoolean(dView.GetRowCellValue(i, dView.Columns[2]));
                                            dkcustomer.Quoctich       = Convert.ToInt32(dView.GetRowCellValue(i, dView.Columns[3]).ToString());
                                            dkcustomer.Sophong        = Convert.ToInt32(gvDangky.GetRowCellValue(i, gvDangky.Columns[0]));
                                            dkcustomer.DateCheckin    = Convert.ToDateTime(dateCheckin.EditValue.ToString());
                                            dkcustomer.DateCheckout   = Convert.ToDateTime(dateCheckout.EditValue.ToString());
                                            dkcustomer.GioCheckin     = DateTime.Now.ToShortTimeString();
                                            dkcustomer.GioCheckout    = "12:00";
                                            edit_dkkhach.CMND         = dkcustomer.CMND;
                                            edit_dkkhach.Hoten        = dkcustomer.Hoten;
                                            edit_dkkhach.Gioitinh     = dkcustomer.Gioitinh;
                                            edit_dkkhach.Quoctich     = dkcustomer.Quoctich;
                                            edit_dkkhach.DateCheckin  = dkcustomer.DateCheckin;
                                            edit_dkkhach.DateCheckout = dkcustomer.DateCheckout;
                                            edit_dkkhach.IdKH         = dkcustomer.IdKH;
                                            db.SaveChanges();
                                        }
                                    }
                                }
                            }
                        }
                        var update = db.Dangky.FirstOrDefault(m => m.Id == id);
                        update.Phong = phong.ToString();
                        db.SaveChanges();
                        t = 0;
                    }
                }
                if (tam == 2)
                {
                    if (txtSo.Text != null)
                    {
                        var id = Convert.ToInt32(txtSo.Text);
                        if (gcDangky.DataSource == null)
                        {
                            var delid = db.Dangky.FirstOrDefault(m => m.Id == id);
                            db.Dangky.Remove(delid);
                            db.SaveChanges();
                            var deldk = db.DK_Customers.FirstOrDefault(m => m.IdDK == id);
                            db.DK_Customers.Remove(deldk);
                            var deldkp = db.DangKyPhong.Where(m => m.IDDK == id).ToList();
                            foreach (var item in deldkp)
                            {
                                db.DangKyPhong.Remove(item);
                            }
                            var listdkp = db.DangKyPhong.Where(m => m.IDDK == id).ToList();
                            foreach (var item in listdkp)
                            {
                                var room = db.Rooms.Where(m => m.Sophong == item.SoPhong).First();
                                room.Status = 1;
                            }
                            db.SaveChanges();
                        }
                        else
                        {
                            var dkp = db.DangKyPhong.Where(m => m.IDDK == id).OrderBy(m => m.SoPhong).ToList();
                            if (lstdkp.Count != 0)
                            {
                                foreach (var item in lstdkp)
                                {
                                    db.DangKyPhong.Remove(item);
                                    var deldkk = db.DK_Customers.Where(m => m.Sophong == item.SoPhong).First();
                                    db.DK_Customers.Remove(deldkk);
                                    var room = db.Rooms.Where(m => m.Sophong == item.SoPhong).First();
                                    room.Status = 1;
                                }
                                for (int i = 0; i < gvDangky.RowCount; i++)
                                {
                                    phong.Trim();
                                    phong += gvDangky.GetRowCellValue(i, gvDangky.Columns[0]).ToString();
                                    if (i < gvDangky.RowCount - 1)
                                    {
                                        phong += ",";
                                    }
                                }
                                var update = db.Dangky.FirstOrDefault(m => m.Id == id);
                                update.Phong = phong.ToString();
                                db.SaveChanges();
                            }
                            else
                            {
                                foreach (var item in lstdkk)
                                {
                                    db.DK_Customers.Remove(item);
                                }
                                db.SaveChanges();
                            }
                        }
                    }
                }
                MessageBox.Show("Lưu thành công!");
            }
        }
Example #12
0
        private void ThiThu_Load(object sender, EventArgs e)
        {
            boDe     = BoDe.boDe;
            soCauThi = boDe.Count;
            dS.EnforceConstraints = false;
            this.cTBAITHITableAdapter.Connection.ConnectionString = Program.connstr;

            BoDe b = (BoDe)boDe[index];

            lblNOIDUNG.Text = "Câu " + index + 1 + ": " + b.NoiDung;
            rdoA.Text       = b.DapAnA;
            rdoB.Text       = b.DapAnB;
            rdoC.Text       = b.DapAnC;
            rdoD.Text       = b.DapAnD;
            Dangky g = Dangky.dangky;

            soCauThi            = g.SoCauThi;
            lblMONHOC.Text      = "Môn: " + Program.maMH;
            lblLOP.Text         = "Lớp: " + Program.mMalop;
            lblNGAYTHI.Text     = "Ngày thi: " + g.NgayThi.ToString("dd/MM/yyyy");
            lblTRINHDO.Text     = "Trình độ: " + g.TrinhDo;
            btnCAUTRUOC.Enabled = false;
            mm         = g.ThoiGian;
            t.Interval = 1000;// bộ tính là 1s

            t.Tick += new EventHandler(this.t_Tick);

            t.Start();
            //Copy dữ liệu từ bộ đề sang chi tiết bài thi
            int i = 1;

            foreach (BoDe b2 in BoDe.boDe)
            {
                String         maCH    = b2.MaCH;
                String         noiDung = b2.NoiDung;
                String         loaiCH  = b2.LoaiCH;
                String         dapAn   = b2.DapAn;
                String         maMH    = b2.MaMH;
                String         maTD    = b2.MaTD;
                String         maGV    = b2.MaGV;
                DataTable      lc      = Program.ExecSqlDataTable("EXEC SP_GET_LUA_CHON '" + maCH + "'");
                List <LuaChon> listLC  = convertToListLC(lc);
                LuaChon.lc = listLC;
                LuaChon[] arrluachon  = listLC.ToArray();
                String    A           = arrluachon[0].TenLC;
                String    B           = arrluachon[1].TenLC;
                String    C           = arrluachon[2].TenLC;
                String    D           = arrluachon[3].TenLC;
                String    dapAnDaChon = "";
                CT_BaiThi ct          = new CT_BaiThi(maCH, i, noiDung, A, B, C, D, dapAn, dapAnDaChon);
                CT_BaiThi.ct_baiThi.Add(ct);
                i++;
            }
            /*cập nhật thông báo đáp án đã chọn*/
            //     capNhatThongBaoDapAnDaChon();
            numericUpDownCAUINDEX.Maximum = 100;
            numericUpDownCAUINDEX.Minimum = 1;

            summarylistview.View          = View.Details;
            summarylistview.GridLines     = true;
            summarylistview.FullRowSelect = true;
            foreach (CT_BaiThi ct in CT_BaiThi.ct_baiThi)
            {
                String[] arr = new string[2];
                arr[0] = ct.getThuTu().ToString();
                arr[1] = ct.getDapAnDaChon().ToString();
                ListViewItem baiThi = new ListViewItem(arr);
                this.summarylistview.Items.Add(baiThi);
            }
        }