Beispiel #1
0
        public ActionResult Create(HocVien hocVien, HttpPostedFileBase hinhAnh)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string path = "";
                    if (hinhAnh != null && hinhAnh.ContentLength > 0)
                    {
                        string extension = Path.GetExtension(hinhAnh.FileName);

                        if (extension.Equals(".jpg") || extension.Equals(".png") || extension.Equals(".jpeg"))
                        {
                            path = Path.Combine(Server.MapPath("~/Img/HocVien/"), hinhAnh.FileName);
                            hinhAnh.SaveAs(path);
                        }

                        hocVien.HinhAnh = hinhAnh.FileName;
                        var _daoHocVien = new HocVienDao();
                        hocVien.NgayDangKy = DateTime.Now;
                        int _maGiaoVien = _daoHocVien.Insert(hocVien);

                        if (_maGiaoVien > 0)
                        {
                            if (hocVien.Email == null)
                            {
                                return(RedirectToAction("Index", "HocVien"));
                            }
                            else
                            {
                                string content = System.IO.File.ReadAllText(Server.MapPath("~/Assets/Email/HocVien.html"));

                                content = content.Replace("{{TenHV}}", hocVien.TenHocVien.ToString());
                                content = content.Replace("{{NgaySinh}}", hocVien.NgaySinh.ToString());
                                content = content.Replace("{{SDT}}", hocVien.SDT.ToString());
                                content = content.Replace("{{DiaChi}}", hocVien.DiaChi.ToString());
                                content = content.Replace("{{NgayDangKy}}", hocVien.NgayDangKy.ToString());

                                new MailHelper().SendMail(hocVien.Email, "Chào mừng em đã tham gia vào đại gia đình Đan Thanh!", content);
                                //SetAlert("")
                                return(RedirectToAction("Index", "HocVien"));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Có lỗi khi thêm học viên");
                        }
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                float n = float.Parse(textBox4.Text);
                if (!(0 <= n && n <= 10))
                {
                    textBox4.Text = "";
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Vui lòng nhập lại");
            }
            try
            {
                float m = float.Parse(textBox5.Text);
                if (!(0 <= m && m <= 10))
                {
                    textBox5.Text = "";
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Vui lòng nhập lại");
            }
            HocVien hv = new HocVien();

            hv.MSSV     = textBox1.Text;
            hv.Hoten    = textBox2.Text;
            hv.SDT      = int.Parse(textBox3.Text);
            hv.DiemToan = float.Parse(textBox4.Text.Trim());
            hv.DiemVan  = float.Parse(textBox5.Text);
            float dtb = float.Parse(textBox4.Text) + float.Parse(textBox5.Text) / 2;

            hv.DTB = dtb;
            try
            {
                FileStream      fs = new FileStream("D:\\test.txt", FileMode.Append);
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(fs, hv);
                fs.Close();

                textBox1.ResetText();
                textBox2.ResetText();
                textBox3.ResetText();
                textBox4.ResetText();
                textBox5.ResetText();

                MessageBox.Show("Thành công");
            }
            catch
            {
                MessageBox.Show("Thêm thất bại");
            }
        }
Beispiel #3
0
        private void TraCuuHocVien_Load(object sender, EventArgs e)
        {
            HocVien   hv = new HocVien();
            DataTable tb = new DataTable();

            tb = hv.getAll(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword());
            cbxMaHV.DataSource    = tb;
            cbxMaHV.ValueMember   = tb.Columns[0].ToString();
            cbxMaHV.DisplayMember = tb.Columns[0].ToString();
        }
Beispiel #4
0
 public JsonResult AddNew(AddNewHS_LOPModel data)
 {
     using (ELearningDB db = new ELearningDB())
     {
         HocVien    hv = db.HocViens.Find(data.ID);
         LopKiemTra l  = db.LopKiemTras.Find(data.MaLop);
         l.HocViens.Add(hv);
         db.SaveChanges();
         return(Json(new { success = true }));
     }
 }
Beispiel #5
0
        public FrLyLich()
        {
            InitializeComponent();
            cb_Lop.DataSource    = new LopDAO().GetAll();
            cb_Lop.DisplayMember = "Ten";
            cb_Lop.ValueMember   = "ID";

            this.Text    = "Thêm học viên";
            btn_Luu.Text = "Thêm học viên";
            lbMaHV.Text  = "";
            hv           = new HocVien();
        }
Beispiel #6
0
        /// <summary>
        /// Nạp danh sách chưa có lớp lên giao diện
        /// </summary>
        public void LoadDSHVChuaCoLop()
        {
            gridDSHV.Rows.Clear();

            dsChuaCoLop = HocVien.DanhSachChuaCoLop();

            foreach (var i in dsChuaCoLop)
            {
                string[] s = { i.MaHV, i.HOCVIEN.TenHV, i.MaPhieu, i.KHOAHOC.TenKH };
                gridDSHV.Rows.Add(s);
            }
        }
 public bool Update(HocVien obj)
 {
     using (IDbConnection db = new SqlConnection(Helper.ConnectionString))
     {
         if (db.State == ConnectionState.Closed)
         {
             db.Open();
         }
         int result = db.Execute("sp_HocVien_Update", new { MaHV = obj.MaHV, TenHV = obj.TenHV, HoHV = obj.HoHV, NgaySinh = obj.NgaySinh, SoCMND = obj.SoCMND, NgayCapCMND = obj.NgayCapCMND, SDT = obj.SDT, DiaChi = obj.DiaChi, DiemTH = obj.DiemTH }, commandType: CommandType.StoredProcedure);
         return(result != 0);
     }
 }
Beispiel #8
0
        private void frmThayDoiThongTinHV_Load(object sender, EventArgs e)
        {
            hv = HocVien.Select(GlobalSettings.UserID);

            txtMaHV.Text       = hv.MaHV;
            txtTenHV.Text      = hv.TenHV;
            dateNgaySinh.Value = (DateTime)hv.NgaySinh;
            cboGioiTinh.Text   = hv.GioiTinhHV;
            txtDiaChi.Text     = hv.DiaChi;
            txtSDT.Text        = hv.SdtHV;
            txtEmail.Text      = hv.EmailHV;
        }
Beispiel #9
0
        private void button5_Click(object sender, EventArgs e)
        {
            FileStream      fs = new FileStream("D:\\test.txt", FileMode.Open);
            BinaryFormatter bF = new BinaryFormatter();
            HocVien         hv = new HocVien();

            while (fs.Position < fs.Length)
            {
                hv = (HocVien)bF.Deserialize(fs);
                richTextBox1.Text += hv.MSSV + "\n" + hv.Hoten + "\n" + hv.SDT + "\n" + hv.DiemToan + "\n" + hv.DiemVan + "\n" + hv.DTB + "\n\n";
            }
        }
 public static HocVien Save(HocVien obj, EntityState state)
 {
     if (state == EntityState.Added)
     {
         obj.MaHV = _container.Resolve <IHocVienRepository>().Insert(obj);
     }
     else
     {
         _container.Resolve <IHocVienRepository>().Update(obj);
     }
     return(obj);
 }
        public List <HocVien> getListHocVien()
        {
            DataTable      data = HocVienDAO.Instance.getListHocVien();
            List <HocVien> list = new List <HocVien>();

            foreach (DataRow item in data.Rows)
            {
                HocVien hocVien = new HocVien(item);
                list.Add(hocVien);
            }
            return(list);
        }
Beispiel #12
0
 public ActionResult Edit(HocVien hv)
 {
     using (ELearningDB db = new ELearningDB())
     {
         HocVien hocvien = db.HocViens.Find(hv.ID);
         hocvien.HoVaTen  = hv.HoVaTen;
         hocvien.Email    = hv.Email;
         hocvien.NgaySinh = hv.NgaySinh;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Beispiel #13
0
        private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            int     maHV    = (int)gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaHV");
            HocVien hocVien = HocVienBUS.Instance.getHocVien(maHV);

            edtMaHV.Text             = hocVien.MaHV.ToString();
            edtHoTen.Text            = hocVien.HoTen;
            dateEdtNgaySinh.DateTime = hocVien.NgaySinh;
            edtDiaChi.Text           = hocVien.DiaChi;
            edtSoDT.Text             = hocVien.SoDienThoai;
            edtGioiTinh.Text         = hocVien.GioiTinh;
        }
Beispiel #14
0
        public bool Insert(HocVien item)
        {
            try
            {
                db.HocViens.Add(item);
                db.SaveChanges();
                //Them mon hoc

                List <Lop_MonHoc> monhoc  = db.Lop_MonHoc.Where(x => x.LopID == item.LopID).ToList();
                HocVien_MonHoc    temp_mh = new HocVien_MonHoc();
                temp_mh.HocVienID = item.ID;
                temp_mh.Diem      = 0;
                foreach (Lop_MonHoc mh in monhoc)
                {
                    temp_mh.MonHocID = mh.MonHocID;
                    new HocVienDAO().Add_HocVien_MonHoc(temp_mh);
                }

                // Them mon the luc

                List <MonTheLuc> montheluc = db.MonTheLucs.ToList();
                HocVien_TheLuc   temp_mtl  = new HocVien_TheLuc();
                temp_mtl.HocVienID = item.ID;
                temp_mtl.KetQua    = 0;
                foreach (var mtl in montheluc)
                {
                    temp_mtl.MonTheLucID = mtl.ID;
                    new HocVienDAO().Add_HocVien_MonTheLuc(temp_mtl);
                }

                //Them mon cong tac dang

                List <CongTacDang>  monctd    = db.CongTacDangs.ToList();
                HocVien_CongTacDang temp_mctd = new HocVien_CongTacDang();
                temp_mctd.HocVienID = item.ID;
                temp_mctd.Diem      = 0;
                foreach (var mctd in monctd)
                {
                    temp_mctd.CongTacDangID = mctd.ID;
                    new HocVienDAO().Add_HocVien_CongTacDang(temp_mctd);
                }

                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                var x = e.ToString();
                MessageBox.Show(x);
                return(false);
            }
        }
        public bool xoaHocVien(int maHV)
        {
            HocVien hocVien = new HocVien()
            {
                MaHV = maHV
            };

            using (var db = new TTTA_DBEntities())
            {
                db.Entry(hocVien).State = System.Data.Entity.EntityState.Deleted;
                return(db.SaveChanges() > 0);
            }
        }
Beispiel #16
0
        public void XoaListHV(List <string> mahv)
        {
            QLTTDayThem db = new QLTTDayThem();

            for (int i = 0; i < mahv.Count; i++)
            {
                HocVien hv = db.HocViens.Find(mahv[i]);
                LopHoc  lh = db.LopHocs.Find(hv.MaLH);
                lh.SiSo = lh.GetSiSo() - 1;
                db.HocViens.Remove(hv);
                db.SaveChanges();
            }
        }
        public List <HocVien> GetList()
        {
            List <HocVien> list = new List <HocVien>();

            DataTable data = DataProvider.Instance.ExecuteQuery("SELECT * FROM dbo.HocVien");

            foreach (DataRow item in data.Rows)
            {
                HocVien obj = new HocVien(item);
                list.Add(obj);
            }
            return(list);
        }
Beispiel #18
0
        public ActionResult CreateDetails(HoaDonDetails hoaDonDetails)
        {
            var hoaDonDao  = new HoaDonDao();
            var ctHDDao    = new CT_HoaDonDao();
            var lopHocDao  = new LopHocDao();
            var hocVienDao = new HocVienDao();

            var hocVien = new HocVien();
            var ctHD    = new CT_HoaDon();
            var lopHoc  = new LopHoc();
            var hoaDon  = new HoaDon();

            return(RedirectToAction("Index"));
        }
        public IActionResult DocFileText()
        {
            var content = System.IO.File.ReadAllLines("HocVien.txt");
            var hocvien = new HocVien
            {
                MaSo          = int.Parse(content[0]),
                TenHocVien    = content[1],
                SoDienThoai   = content[2],
                DiemTrungBinh = double.Parse(content[3]),
                GioiTinh      = content[4] == "true"? true : false
            };

            return(View("ThongTin", hocvien));
        }
Beispiel #20
0
        public JsonResult Add_Edit(string id, string hoten, string ngaysinh, string sdt, string email, string diachi, string idtaikhoan)
        {
            var hv = new HocVien();

            if (id != null)
            {
                var rId = int.Parse(id);
                hv = db.HocViens.Single(z => z.ID == rId);
            }
            hv.HoTen    = hoten;
            hv.NgaySinh = ngaysinh.Replace('-', '/');
            hv.SDT      = sdt;
            hv.Email    = email;
            hv.DiaChi   = diachi;
            if (id == null)// Just Add Info
            {
                var idTK     = int.Parse(idtaikhoan);
                var lhv      = db.TaiKhoans.Where(z => z.IDChucVu == 3);
                var taikhoan = lhv.SingleOrDefault(z => z.ID == idTK);
                if (taikhoan == null) // Not Create TK
                {
                    return(Json(new { data = false }));
                }
                if (taikhoan != null)
                {
                    var hocvien = db.HocViens.SingleOrDefault(z => z.IDTaiKhoan == taikhoan.ID);
                    if (hocvien != null)
                    {    // Already have infomation connect to this account
                        return(Json(new { data = false }));
                    }
                    else
                    {
                        hv.IDTaiKhoan = idTK; // Have account but not have infomation
                    }
                }
            }
            try
            {
                if (id == null)
                {
                    db.HocViens.Add(hv);
                }
                db.SaveChanges();
                return(Json(new { data = true }));
            }
            catch
            {
                return(Json(new { data = false }));
            }
        }
        public IActionResult DemoJson()
        {
            var hocvien = new HocVien
            {
                MaSo     = 1,
                HoTen    = "loc",
                GioiTinh = true,
                SoDT     = "012145646",
                DiemTb   = 8.1,
            };

            //return Json(hocvien);
            return(Json(new { status = true, TrungTam = "Nhất Nghệ", NgayTHanhLap = new DateTime(2013, 3, 10) }));
        }
Beispiel #22
0
        public IActionResult DocFileText()
        {
            var content = System.IO.File.ReadAllLines("HocVien.txt");
            var hocvien = new HocVien
            {
                MaSo       = int.Parse(content[0]),
                TenHocVien = content[1],
                SDT        = int.Parse(content[2]),
                DiemTB     = double.Parse(content[3]),
                Gioitinh   = content[4] == "true" ? true : false
            };

            return(View("Index", hocvien));
        }
        public IActionResult Post([FromBody] HocVien hocVien)
        {
            if (ModelState.IsValid)
            {
                var hv = Find(hocVien.MaHV);
                if (hv == null)
                {
                    dsHocVien.Add(hocVien);
                    return(Ok());
                }

                return(BadRequest());
            }
            return(BadRequest());
        }
 public string Insert(HocVien obj)
 {
     using (IDbConnection db = new SqlConnection(Helper.ConnectionString))
     {
         if (db.State == ConnectionState.Closed)
         {
             db.Open();
         }
         DynamicParameters p = new DynamicParameters();
         //p.Add("@MaHV", dbType: DbType.String, direction:ParameterDirection.Output,size:20);
         p.AddDynamicParams(new { MaHV = "", TenHV = obj.TenHV, HoHV = obj.HoHV, NgaySinh = obj.NgaySinh, SoCMND = obj.SoCMND, NgayCapCMND = obj.NgayCapCMND, SDT = obj.SDT, DiaChi = obj.DiaChi, DiemTH = obj.DiemTH, NgayDK = "", KyThi = "" });
         db.Execute("sp_HocVien_Insert", p, commandType: CommandType.StoredProcedure);
         return(p.Get <string>("@MaHV"));
     }
 }
Beispiel #25
0
 public ActionResult FirstLogin(int ID)
 {
     using (ELearningDB db = new ELearningDB())
     {
         HocVien hv = db.HocViens.Find(ID);
         if (hv.HoVaTen != null)
         {
             Session.Abandon();
             return(RedirectToAction("Index", "Login"));
         }
         HocVienModel hocvien = new HocVienModel();
         hocvien.ID = hv.ID;
         return(View(hocvien));
     }
 }
        /// <summary>
        /// Nạp danh sách học viên
        /// </summary>
        public void InitializeHocVien()
        {
            gridDSHV.AutoGenerateColumns = false;

            Thread th = new Thread(() =>
            {
                object dshv = HocVien.SelectAll();

                gridDSHV.Invoke((MethodInvoker) delegate
                {
                    gridDSHV.DataSource = dshv;
                });
            });

            th.Start();
        }
Beispiel #27
0
 private void btnSua_Click(object sender, EventArgs e)
 {
     try
     {
         if ((txtTenHocVien.Text == "") || (txtSDT.Text == "") || (txtDiaChi.Text == "") || (cbGioiTinh.Text == "") || (cbNgayRanh.Text == "") || (cbCaRanh.Text == "") || (cbTrinhDoHienTai.Text == "") || (cbTrinhDoMuonHoc.Text == ""))
         {
             MessageBox.Show("Bạn còn số liệu chưa nhập ");
             return;
         }
         string _maHV = dgvDSHVTiemNang.CurrentRow.Cells[0].Value.ToString();//cbbMaHocVien.Text;
         //Them hoc vien
         _objHV = new HocVien(
             _maHV,
             txtTenHocVien.Text, //hoten
             cbGioiTinh.Text,    //gioitinh
             txtDiaChi.Text,     //diachi
             txtSDT.Text,        //sdt
             null,
             Double.Parse("0"));
         //Them thong tin dang ky cua hoc vien
         _objThongTinDangKy = new ThongTinDangKy(
             _maHV,
             dtNgayLapTTHV.Text,
             "Chưa học",
             Int32.Parse("0"),
             _objNgayHocBUS.GetMa_TheoTen(cbNgayRanh.Text),       //mangayranh
             _objCaHocBUS.GetMa_TheoTen(cbCaRanh.Text),           //macaranh
             _objTrinhDoBUS.GetMa_TheoTen(cbTrinhDoHienTai.Text), //matrinhdohientai
             _objTrinhDoBUS.GetMa_TheoTen(cbTrinhDoMuonHoc.Text), //matrinhdomuonhoc
             _objTrinhDoBUS.GetMa_TheoTen(cbTrinhDoMuonHoc.Text), //matrinhdoduochoc
             null);
         if (_objHVBUS.EditHocVien(_objHV) && _objThongTinDangKyBUS.EditThongTinDangKy(_objThongTinDangKy))
         {
             LoadData();
             MessageBox.Show("Sửa Thành Công ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             resettextbox();
         }
         else
         {
             MessageBox.Show("Sửa Thất Bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch
     {
         MessageBox.Show("Bạn đã nhập sai thông tin, vui lòng nhập lại  !", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void btnHienTatCa_Click(object sender, EventArgs e)
        {
            gridDSHV.AutoGenerateColumns = false;

            thHocVien = new Thread(() =>
            {
                //thPhieuGhiDanh.Join();

                object source = HocVien.SelectAll();

                gridDSHV.Invoke((MethodInvoker) delegate
                {
                    gridDSHV.DataSource = source;
                });
            });
            thHocVien.Start();
        }
        public IActionResult DemoJson()
        {
            var HV = new HocVien
            {
                MaSo          = 123123, TenHocVien = "Nguyen Van A", GioiTinh = true
                , SoDienThoai = "0909090900", DiemTrungBinh = 12
            };

            var data = new
            {
                HocVien      = HV,
                TrungTam     = "Nhat Nghe",
                NgayThanhLap = new DateTime(1234, 12, 12)
            };

            return(Json(data));
        }
Beispiel #30
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Bạn có muốn xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    HocVien.Delete(gridDSHV.SelectedRows[0].Cells["clmMaHV"].Value.ToString());

                    MessageBox.Show("Xóa học viên thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    btnXemTatCa_Click(sender, e);
                }
            }
            catch
            {
                MessageBox.Show("Có lỗi xảy ra", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }