Example #1
0
        public string DatHang(string noigiaoSP)
        {
            dondat             dd = new dondat();
            List <ItemGioHang> kq = Session["cart"] as List <ItemGioHang>;
            thanhvien          tv = Session["login"] as thanhvien;

            if (kq == null || tv == null)
            {
                return("err");
            }
            else
            {
                dd.TenDangNhap = tv.TenDangNhap;
                dd.TrangThai   = "Đã đặt hàng, chờ xác nhận";
                dd.NoiGiao     = noigiaoSP;
                dd.NgayDat     = DateTime.Now;
                db.dondats.Add(dd);

                foreach (var item in kq)
                {
                    ct_dondat ctdd = new ct_dondat();
                    ctdd.MaDonDat  = dd.MaDonDat;
                    ctdd.MaSanPham = item.MaSP;
                    ctdd.SoLuong   = item.SoLuong;
                    db.ct_dondat.Add(ctdd);
                }
                db.SaveChanges();
                Session["cart"] = null;
                return("ok");
            }
        }
Example #2
0
        public bool Them_NV(thanhvien tv)
        {
            string query = $"Insert into Thanhvien(MaTV,STT,hoten,loaithanhvien,soDT,email,diachi,diemtichluy) values(N'{tv._matv}',{tv._stt},N'{tv._hoten}',N'{tv._loaitv}',N'{tv._sodt}',N'{tv._email}',N'{tv._diachi}',{tv._diemTl})";

            Load_DB(query);
            return(true);
        }
Example #3
0
        public bool Sua_NV(thanhvien tv)
        {
            string query = $"update Thanhvien set Matv=N'{tv._matv}',STT={tv._stt},hoten=N'{tv._hoten}',loaithanhvien=N'{tv._loaitv}',soDT='{tv._sodt}',email=N'{tv._email}',diachi=N'{tv._diachi}',diemtichluy={tv._diemTl} Where MaTV=N'{tv._matv}' ";

            Load_DB(query);
            return(true);
        }
        public IHttpActionResult Putthanhvien(int id, thanhvien thanhvien)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != thanhvien.matv)
            {
                return(BadRequest());
            }

            db.Entry(thanhvien).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Exists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult Postthanhvien([FromBody] thanhvien thanhvien)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.thanhviens.Add(thanhvien);
            try
            {
                db.SaveChanges();
            }
            catch
            {
                if (thanhvienExists(thanhvien.tendangnhap))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = thanhvien.matv }, thanhvien));
        }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ViewState["stateThanhVien"] != null)
            {
                thanhviens = (List <thanhvien>)ViewState["stateThanhVien"];
            }
            else
            {
                thanhviens = new List <thanhvien>();
            }

            GridView1.DataSource = thanhviens;
            GridView1.DataBind();

            if (!IsPostBack)
            {
                DateTime ngaybatdau  = new DateTime();
                DateTime ngayketthuc = new DateTime();;
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString()))
                {
                    // Goi cau lenh procedure
                    using (SqlCommand cmd = new SqlCommand("THOIGIANDANGKY_GETTIME1", conn))
                    {
                        //Gan keu truy van la Procedure
                        cmd.CommandType = CommandType.StoredProcedure;
                        //Truyen bien vao cau lenh
                        conn.Open();
                        SqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            ngaybatdau  = reader.GetDateTime(1);
                            ngayketthuc = reader.GetDateTime(2);
                        }

                        conn.Close();
                    }

                    if (DateTime.Now < ngaybatdau || DateTime.Now > ngayketthuc)
                    {
                        Response.Redirect("baoloithoigiandangky.aspx");
                    }

                    thanhviens = new List <thanhvien>();
                    taoma tm = new taoma();
                    txtMaDeTai.Text = tm.taomangaunhien("DX");

                    thanhvien tv1 = new thanhvien();
                    tv1.MaNV  = ((dangnhapnguoidung)Session["dangnhap"]).cb_id;
                    tv1.Hoten = ((dangnhapnguoidung)Session["dangnhap"]).cb_hoten;
                    tv1.Vitri = "Chủ nhiệm đề tài";
                    tv1.Email = ((dangnhapnguoidung)Session["dangnhap"]).cb_email;
                    thanhviens.Add(tv1);
                    ViewState["stateThanhVien"] = thanhviens;
                    GridView1.DataSource        = thanhviens;
                    GridView1.DataBind();
                }
            }
        }
Example #7
0
        public ActionResult Updatepass(string user)
        {
            if (Session["login"] == null)
            {
                return(RedirectToAction("Index"));
            }
            thanhvien tv = db.thanhviens.Single(n => n.TenDangNhap == user);

            return(PartialView(tv));
        }
        public IHttpActionResult Getthanhvien(int id)
        {
            thanhvien thanhvien = db.thanhviens.Find(id);

            if (thanhvien == null)
            {
                return(NotFound());
            }

            return(Ok(thanhvien));
        }
Example #9
0
 public ActionResult MemberEdit([Bind(Include = "TenDangNhap,MatKhau,HoTen,NgaySinh,GioiTinh,DiaChi,DienThoai,Email,HinhAnh")] thanhvien thanhvien)
 {
     if (Session["admin"] == null)
     {
         return(RedirectToAction("Login"));
     }
     if (ModelState.IsValid)
     {
         db.Entry(thanhvien).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Member"));
     }
     return(View(thanhvien));
 }
        public IHttpActionResult Deletethanhvien(int id)
        {
            thanhvien thanhvien = db.thanhviens.Find(id);

            if (thanhvien == null)
            {
                return(NotFound());
            }

            db.thanhviens.Remove(thanhvien);
            db.SaveChanges();

            return(Ok(thanhvien));
        }
Example #11
0
        public ActionResult Account(string id)
        {
            thanhvien tamp = db.thanhviens.Find(id);

            if (Session["login"] == null)
            {
                return(RedirectToAction("Index"));
            }
            if (((thanhvien)Session["login"]).TenDangNhap != tamp.TenDangNhap)
            {
                return(RedirectToAction("Index"));
            }
            return(View(tamp));
        }
Example #12
0
        public ActionResult MemberDele(string idloaisp)
        {
            if (Session["admin"] == null)
            {
                return(RedirectToAction("Login"));
            }
            thanhvien ls = db.thanhviens.Find(idloaisp);

            if (ls != null)
            {
                db.thanhviens.Remove(ls);
                db.SaveChanges();
            }
            return(RedirectToAction("Member"));
        }
Example #13
0
        public ActionResult Checkout()
        {
            thanhvien tv = new thanhvien();

            if (Session["login"] != null)
            {
                thanhvien t = (thanhvien)Session["login"];
                tv = db.thanhviens.Find(t.TenDangNhap);
            }
            List <ItemGioHang> kq = GetGioHang();

            ViewBag.cart     = kq;
            ViewBag.TongTien = TongTien();
            return(View(tv));
        }
Example #14
0
        public ActionResult Singup(string url, string username, string password)
        {
            thanhvien tv = new thanhvien();

            tv.TenDangNhap = username;
            tv.MatKhau     = password;
            db.thanhviens.Add(tv);
            int sr = db.SaveChanges();

            if (sr > 0)
            {
                Session["login"] = tv;
            }
            return(Redirect(url));
        }
Example #15
0
        public ActionResult ThemBinhLuan(int?masp, string nd)
        {
            thanhvien tv = Session["login"] as thanhvien;

            if (tv != null)
            {
                binhluan bl = new binhluan();
                bl.MaSanPham       = masp;
                bl.NoiDungBinhLuan = nd;
                bl.TenDangNhap     = tv.TenDangNhap;
                bl.NgayBinhLuan    = DateTime.Now;
                db.binhluans.Add(bl);
                db.SaveChanges();
            }
            return(PartialView(db.binhluans.Where(n => n.MaSanPham == masp).ToList()));
        }
Example #16
0
        public ActionResult Account([Bind(Include = "TenDangNhap,MatKhau,HoTen,NgaySinh,GioiTinh,DiaChi,DienThoai,Email,HinhAnh")] thanhvien thanhvien, FormCollection f)
        {
            string gtt = f["gtinh"].ToString();

            if (gtt == "N")
            {
                thanhvien.GioiTinh = "Nam";
            }
            else
            {
                thanhvien.GioiTinh = "Nữ";
            }
            db.Entry(thanhvien).State = EntityState.Modified;
            db.SaveChanges();

            return(View(thanhvien));
        }
Example #17
0
        public ActionResult MemberEdit(string id)
        {
            if (Session["admin"] == null)
            {
                return(RedirectToAction("Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            thanhvien thanhvien = db.thanhviens.Find(id);

            if (thanhvien == null)
            {
                return(HttpNotFound());
            }
            return(View(thanhvien));
        }
Example #18
0
        public string Login(string username, string password)
        {
            thanhvien tv = db.thanhviens.Find(username);

            if (tv != null)
            {
                if (tv.MatKhau != password)
                {
                    return("Tên đăng nhập hoặc mật khẩu không chính xác");
                }
                else
                {
                    Session["login"] = tv;
                    return("ok");
                }
            }
            return("Tên đăng nhập hoặc mật khẩu không chính xác");
        }
Example #19
0
        protected void btnthem_Click(object sender, EventArgs e)
        {
            thanhvien tv = new thanhvien();

            tv.MaNV  = txtMaCB.Text;
            tv.Hoten = txtHoTen.Text;
            tv.Vitri = ddlVitri.Text;
            tv.Email = txtemail.Text;

            thanhviens.Add(tv);
            ViewState["stateThanhVien"] = thanhviens;

            GridView1.DataSource = thanhviens;
            GridView1.DataBind();

            txtMaCB.Text  = "";
            txtHoTen.Text = "";
            ddlVitri.Text = "";
            txtemail.Text = "";
        }
Example #20
0
        public ActionResult formUpdateBL([Bind(Include = "MaBinhLuan,TenDangNhap,MaSanPham,NgayBinhLuan,NoiDungBinhLuan")] binhluan bl,
                                         int?mabl, string noidungbt, string tdn, int?masp, DateTime nbl)
        {
            binhluan  ble = db.binhluans.Find(mabl);
            sanpham   sp  = db.sanphams.Find(masp);
            thanhvien tv  = db.thanhviens.Find(tdn);

            if (ble == null || sp == null || tv == null)
            {
                return(null);
            }
            ble.MaBinhLuan      = ble.MaBinhLuan;
            ble.NoiDungBinhLuan = noidungbt;
            ble.TenDangNhap     = tdn;
            ble.MaSanPham       = masp;
            ble.NgayBinhLuan    = nbl;
            db.Entry(ble).State = EntityState.Modified;
            db.SaveChanges();
            return(PartialView("ThemBinhLuan", db.binhluans.Where(n => n.MaSanPham == masp).ToList()));
        }
Example #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ViewState["stateThanhVien"] != null)
            {
                thanhviens = (List <thanhvien>)ViewState["stateThanhVien"];
            }
            else
            {
                thanhviens = new List <thanhvien>();
            }

            GridView1.DataSource = thanhviens;
            GridView1.DataBind();

            if (!IsPostBack)
            {
                thanhviens = new List <thanhvien>();

                //load noi dung de xuat de tai
                txtMaThuyetMinh.Text = Session["CapNhatThuyetMinh"].ToString();

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString()))
                {
                    // Goi cau lenh procedure
                    using (SqlCommand cmd = new SqlCommand("THUYETMINHDETAI_SELECT_ROW", conn))
                    {
                        //Gan keu truy van la Procedure
                        cmd.CommandType = CommandType.StoredProcedure;
                        //Truyen bien vao cau lenh
                        cmd.Parameters.AddWithValue("@TMDT_ID", txtMaThuyetMinh.Text);
                        conn.Open();
                        SqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            txtMaDeTai.Text    = reader.GetString(1);
                            txtTenDeTai.Text   = reader.GetString(2);
                            chuoiLV            = reader.GetString(3);
                            chuoiLH            = (reader.IsDBNull(4)? "" : reader.GetString(4));
                            txtTGThucHien.Text = (reader.IsDBNull(5) ? "" : reader.GetString(5));
                            txtCQCTDT.Text     = (reader.IsDBNull(6) ? "" : reader.GetString(6));
                            txtSDTCQCTDT.Text  = (reader.IsDBNull(7) ? "" : reader.GetString(7));
                            txtDCCQCTDT.Text   = (reader.IsDBNull(8) ? "" : reader.GetString(8));
                            txtDVTH.Text       = (reader.IsDBNull(9) ? "" : reader.GetString(9));
                            txtSDTDVTH.Text    = (reader.IsDBNull(10) ? "" : reader.GetString(10));
                            txtDCTDVTH.Text    = (reader.IsDBNull(11) ? "" : reader.GetString(11));
                            ckeTrongNuoc.Text  = (reader.IsDBNull(12) ? "" : reader.GetString(12));
                            ckeNgoaiNuoc.Text  = (reader.IsDBNull(13) ? "" : reader.GetString(13));


                            ckeDoiTuongNghienCuu.Text   = (reader.IsDBNull(13) ? "" : reader.GetString(29));
                            ckephamvinghiencuu.Text     = (reader.IsDBNull(13) ? "" : reader.GetString(30));
                            ckecachtiepcan.Text         = (reader.IsDBNull(13) ? "" : reader.GetString(31));
                            ckephuongphapnghiencuu.Text = (reader.IsDBNull(13) ? "" : reader.GetString(32));


                            ckeTinhCapThiet.Text = reader.GetString(14);
                            ckeMucTieu.Text      = reader.GetString(15);
                            ckeNoiDung.Text      = reader.GetString(16);

                            chuoispkh = (reader.IsDBNull(17) ? "" : reader.GetString(17));
                            chuoispdt = (reader.IsDBNull(18) ? "" : reader.GetString(18));
                            chuoispud = (reader.IsDBNull(19) ? "" : reader.GetString(19));

                            txtSanPhamKhac.Text  = (reader.IsDBNull(20) ? "" : reader.GetString(20));
                            ckeHieuQua.Text      = reader.GetString(21);
                            ckePTChuyenGiao.Text = (reader.IsDBNull(22) ? "" : reader.GetString(22));

                            txtGioNCKH.Text        = reader.GetString(23);
                            txtKinhPhi.Text        = reader.GetString(24);
                            txtNganSachTruong.Text = reader.GetString(25);
                            txtCacNguonKPKhac.Text = reader.GetString(26);
                        }

                        conn.Close();
                    }
                }

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString()))
                {
                    // Goi cau lenh procedure
                    using (SqlCommand cmd = new SqlCommand("DKDT_THANHVIEN_SELECTDETAI", conn))
                    {
                        //Gan keu truy van la Procedure
                        cmd.CommandType = CommandType.StoredProcedure;
                        //Truyen bien vao cau lenh
                        cmd.Parameters.AddWithValue("@DKDT_ID", txtMaDeTai.Text);
                        conn.Open();
                        SqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            thanhvien tv = new thanhvien();
                            tv.MaNV  = reader.GetString(2);
                            tv.Hoten = reader.GetString(3);
                            tv.Vitri = reader.GetString(4);
                            tv.Email = (reader.IsDBNull(5) ? "" : reader.GetString(5));

                            thanhviens.Add(tv);
                        }

                        conn.Close();
                        GridView1.DataSource = thanhviens;
                        GridView1.DataBind();
                        ViewState["stateThanhVien"] = thanhviens;
                    }
                }

                for (int i = 0; i < chkspud.Items.Count; i++)
                {
                    if (chuoispud.Contains(chkspud.Items[i].Value.ToString()))
                    {
                        chkspud.Items[i].Selected = true;
                    }
                }

                for (int i = 0; i < chkspdt.Items.Count; i++)
                {
                    if (chuoispdt.Contains(chkspdt.Items[i].Value.ToString()))
                    {
                        chkspdt.Items[i].Selected = true;
                    }
                }

                for (int i = 0; i < chkspkh.Items.Count; i++)
                {
                    if (chuoispkh.Contains(chkspkh.Items[i].Value.ToString()))
                    {
                        chkspkh.Items[i].Selected = true;
                    }
                }
            }
        }
Example #22
0
 public bool Them_NV(thanhvien tv)
 {
     return(dal.Them_NV(tv));
 }
Example #23
0
 public bool Sua_NV(thanhvien tv)
 {
     return(dal.Sua_NV(tv));
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ViewState["stateThanhVien"] != null)
            {
                thanhviens = (List <thanhvien>)ViewState["stateThanhVien"];
            }
            else
            {
                thanhviens = new List <thanhvien>();
            }

            GridView1.DataSource = thanhviens;
            GridView1.DataBind();

            if (!IsPostBack)
            {
                thanhviens = new List <thanhvien>();

                //load noi dung de xuat de tai
                txtMaDeTai.Text = Session["CapNhatDeTai"].ToString();

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString()))
                {
                    // Goi cau lenh procedure
                    using (SqlCommand cmd = new SqlCommand("DANGKYDETAI_SELECT_ROW", conn))
                    {
                        //Gan keu truy van la Procedure
                        cmd.CommandType = CommandType.StoredProcedure;
                        //Truyen bien vao cau lenh
                        cmd.Parameters.AddWithValue("@DKDT_ID", txtMaDeTai.Text);
                        conn.Open();
                        SqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            txtTenDeTai.Text         = reader.GetString(1);
                            chuoiLV                  = reader.GetString(2);
                            ckeTinhCapThiet.Text     = reader.GetString(3);
                            ckeMucTieu.Text          = reader.GetString(4);
                            ckeNoiDung.Text          = reader.GetString(5);
                            ckeHieuQua.Text          = reader.GetString(6);
                            ckeSanPham.Text          = reader.GetString(7);
                            txtGioNCKH.Text          = reader.GetString(8);
                            txtKinhPhi.Text          = reader.GetString(9);
                            txtNganSachTruong.Text   = reader.GetString(10);
                            txtCacNguonKPKhac.Text   = reader.GetString(11);
                            txtThoiGianThucHien.Text = reader.GetString(14);
                        }

                        conn.Close();
                    }
                }

                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString()))
                {
                    // Goi cau lenh procedure
                    using (SqlCommand cmd = new SqlCommand("DKDT_THANHVIEN_SELECTDETAI", conn))
                    {
                        //Gan keu truy van la Procedure
                        cmd.CommandType = CommandType.StoredProcedure;
                        //Truyen bien vao cau lenh
                        cmd.Parameters.AddWithValue("@DKDT_ID", txtMaDeTai.Text);
                        conn.Open();
                        SqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            thanhvien tv = new thanhvien();
                            tv.MaNV  = reader.GetString(2);
                            tv.Hoten = reader.GetString(3);
                            tv.Vitri = reader.GetString(4);
                            tv.Email = reader.GetString(5);

                            thanhviens.Add(tv);
                        }

                        conn.Close();
                        GridView1.DataSource = thanhviens;
                        GridView1.DataBind();
                        ViewState["stateThanhVien"] = thanhviens;
                    }
                }
            }
        }