protected void btnUpdate_Click(object senger, EventArgs e) { int ID = int.Parse(Request.QueryString["ID"]); MyContextDataContext db = new MyContextDataContext(); if (txtHanNop.Text != "" && !Regex.IsMatch(txtHanNop.Text, @"^(?<Day>[0-2]\d|[3][0-1])\/(?<Month>[0]\d|[1][0-2])\/(?<Year>(?:[2][01]|[1][6-9])\d{2})\s(?:(?<Hour>[0-1]\d|[2][0-4]):(?<Min>[0-5]\d){1,2}:(?<Sec>[0-5]\d){1,2})$")) { lblKQ.Text = "Đề nghị nhập ngày cho đúng với định dạng [dd/mm/yyyy hh:mm:ss]"; return; } var bt = db.BaiTaps.Single(m => m.Ma == ID); if (bt == null) { lblKQ.Text = "ERR"; return; } if (fUpLoad.FileName.Length > 0) { string fileName = MaLop + "_" + DateTime.Now.Year.ToString("0000") + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00") + "_" + DateTime.Now.Hour.ToString("00") + "h" + DateTime.Now.Minute.ToString("00") + "m" + DateTime.Now.Second.ToString("00") + "s.zip"; string FilePath = Server.MapPath(@"~\Upload\GiaoVien"); string FullName = FilePath + @"\" + fileName; fUpLoad.SaveAs(FullName); bt.AttachFile = @"\Upload\GiaoVien\" + fileName; } bt.Ten = txtTenBT.Text; bt.MoTa = txtMoTa.Text; var Match = Regex.Match(txtHanNop.Text, @"^(?<Day>[0-2]\d|[3][0-1])\/(?<Month>[0]\d|[1][0-2])\/(?<Year>(?:[2][01]|[1][6-9])\d{2})\s(?:(?<Hour>[0-1]\d|[2][0-4]):(?<Min>[0-5]\d){1,2}:(?<Sec>[0-5]\d){1,2})$"); bt.HanNop = new DateTime(int.Parse(Match.Groups["Year"].Value), int.Parse(Match.Groups["Month"].Value), int.Parse(Match.Groups["Day"].Value), int.Parse(Match.Groups["Hour"].Value), int.Parse(Match.Groups["Min"].Value), int.Parse(Match.Groups["Sec"].Value)); db.SubmitChanges(); Response.Redirect("/GiaoVien/Details.aspx?ID=" + MaLop); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["Link"] == string.Empty) return; Link = (@"\" + Request.QueryString["Link"].Replace("/",@"\")).Replace(@"\\",@"\"); var path = Server.MapPath(Link); if (!File.Exists(path)) return; MyContextDataContext db = new MyContextDataContext(); var FileName = Path.GetFileName(Link); if (User.IsInRole("GiaoVien")) { var ClassList = db.BaiTaps.Where(m => m.LopHoc.GiaoVien == User.Identity.Name).Select(m => m.LopHoc.MaLop); var ClassName = FileName.Substring(0, FileName.IndexOf("_")); if (ClassList.Contains(ClassName)) { Response.Redirect(Link); return; } } if (User.IsInRole("SinhVien")) { if (FileName.Contains(User.Identity.Name)) { Response.Redirect(Link); } } Response.Redirect("/Error.aspx"); }
protected void btnCreate_Click(object sender, EventArgs e) { if (txtEmail.Text != "" && !Regex.IsMatch(txtEmail.Text, "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})$")) { lblKQ.Text = "Đề nghị nhập email cho đúng"; return; } if (txtNgaySinh.Text!="" && !Regex.IsMatch(txtNgaySinh.Text, "^(?<Day>\\d{1,2})/(?<Month>\\d{1,2})/(?<Year>(?:\\d{4}|\\d{2}))$")) { lblKQ.Text = "Đề nghị nhập ngày sinh cho đúng"; return; } MyContextDataContext db = new MyContextDataContext(); string UserName = txtUser.Text; var user = db.NguoiDungs.Where(p => p.Username == UserName).FirstOrDefault(); if (user == null) { if (txtUser.Text == "" || txtPass.Text == "" || txtPass1.Text == "" || txtHo.Text == "" || txtTen.Text == "") { lblKQ.Text = "Chưa nhập đầy đủ thông tin"; return; } if (txtPass.Text != txtPass1.Text) { lblKQ.Text = "Mật khẩu chưa khớp"; return; } NguoiDung nd = new NguoiDung(); nd.Username = txtUser.Text; nd.Password = txtPass.Text; nd.Ten = txtTen.Text; nd.HoLot = txtHo.Text; nd.Email = txtEmail.Text; var Match = Regex.Match(txtNgaySinh.Text, "^(?<Day>\\d{1,2})/(?<Month>\\d{1,2})/(?<Year>(?:\\d{4}|\\d{2}))$"); nd.NgaySinh = new DateTime(int.Parse(Match.Groups["Day"].Value), int.Parse(Match.Groups["Month"].Value), int.Parse(Match.Groups["Year"].Value)); nd.GioiTinh = (RaNam.Checked == true) ? true : false; db.NguoiDungs.InsertOnSubmit(nd); db.SubmitChanges(); var a = db.Quyens.FirstOrDefault(p => p.TenQuyen == ddlQuyen.Text); Quyen_NguoiDung q = new Quyen_NguoiDung(); q.Username = txtUser.Text; q.MaQuyen = a.MaQuyen; db.Quyen_NguoiDungs.InsertOnSubmit(q); db.SubmitChanges(); } else { lblKQ.Text = "bị trùng user"; return; } }
protected void Page_Load(object sender, EventArgs e) { int ID = int.Parse(Request.QueryString["ID"]); MyContextDataContext db = new MyContextDataContext(); var bt = db.BaiTaps.Where(m => m.Ma == ID).FirstOrDefault(); MaBT = bt.Ma.ToString(); txtTenBT.Text = bt.Ten.ToString(); txtMoTa.Text = bt.MoTa.ToString(); txtHanNop.Text = bt.HanNop.ToString("dd/MM/yyy HH:mm:ss"); TenLop = bt.LopHoc.TenLop; MaLop = bt.MaLop; MaBT = bt.Ma + ""; }
protected void Page_Load(object sender, EventArgs e) { int EID = int.Parse(Request.QueryString["EID"]); string UID = Request.QueryString["UID"]; MyContextDataContext db= new MyContextDataContext(); var bainop = db.BaiNops.Where(m => m.Username == UID && m.MaBaiTap == EID).FirstOrDefault(); var bt = db.BaiTaps.Where(m => m.Ma == EID).FirstOrDefault(); TenBai = bt.Ten; var lop = db.LopHocs.Where(m => m.MaLop == bt.MaLop).FirstOrDefault(); TenLop = lop.TenLop; MaLop = lop.MaLop; SV = UID; Ten = bainop.NguoiDung.HoLot + bainop.NguoiDung.Ten; }
protected void Page_Load(object sender, EventArgs e) { string ID = Request.QueryString["ID"]; var data = from m in (new MyContextDataContext()).BaiTaps select m; if (data.Count() > 0) { var Result = data.FirstOrDefault(); TenBai = Result.Ten; MyContextDataContext db = new MyContextDataContext(); var lop = db.LopHocs.Where(m => m.MaLop == Result.MaLop).FirstOrDefault(); TenLop = lop.TenLop; MaLop = lop.MaLop; } }