protected void btThem_Click(object sender, EventArgs e) { lbID.Visible = false; QlSachDbDataContext db = new QlSachDbDataContext(); if (btThem.Text == "Thêm mới...") { tbID.Enabled = true; tbID.Text = ""; tbHoten.Text = ""; tbPass.Text = ""; btSua.Enabled = false; btXoa.Enabled = false; rdAdmin.Checked = false; rdNormal.Checked = !rdAdmin.Checked; btThem.Text = "Thêm"; } else { if (!db.DangNhaps.Any(p => p.TenDangNhap == tbID.Text)) { DangNhap dn = new DangNhap(); dn.TenDangNhap = tbID.Text; dn.MatKhau = Encoding.MaHoa(Encoding.key,tbPass.Text); dn.hoten = tbHoten.Text; dn.Quyen = rdAdmin.Checked; db.DangNhaps.InsertOnSubmit(dn); db.SubmitChanges(); //System.Windows.Forms.MessageBox.Show("Thêm tài khoản mới thành công!"); Response.Write("<script>alert('Thêm tài khoản mới thành công!')</script>"); Response.Redirect(Request.RawUrl); //btThem.Text = "Thêm"; //drdID.DataSource = db.DangNhaps.Select(p => p.TenDangNhap); //drdID.DataBind(); //drdID.SelectedValue = tbID.Text; //ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "DoPostBack", "__doPostBack(sender, e)", true); } else { lbID.Visible = true; } } }
partial void UpdateDangNhap(DangNhap instance);
partial void DeleteDangNhap(DangNhap instance);
partial void InsertDangNhap(DangNhap instance);