protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { using (usersTableAdapter anAdapter = new usersTableAdapter()) { usersDataTable aTable; aTable = anAdapter.GetDataByCredentials(Login1.UserName, Login1.Password); if (aTable.Rows.Count == 1) { usersRow aRow = aTable.Rows[0] as usersRow; int userPK = aRow.userID; string userName = aRow.name; Hashtable aHash = new Hashtable() { { "userID", userPK }, { "userName", userName } }; Session.Add("UserInfo", aHash); Session.Add("userID", userPK); Session.Add("name", aRow.name); Session.Add("email", aRow.email); HttpCookie aCookie = new HttpCookie("user"); aCookie["userID"] = aRow.userID.ToString(); Response.Cookies.Add(aCookie); if (Request.QueryString["ReturnUrl"] != string.Empty) { FormsAuthentication.RedirectFromLoginPage(userPK.ToString(), false); FormsAuthentication.SetAuthCookie(userPK.ToString(), false); } } } }
protected void login_in_Click(object sender, EventArgs e) { //usersTableAdapter adpuser = new usersTableAdapter(); //login_txt.Visible = false; string pwd = password.Text; string acount = account.Text; Session["txtname"] = acount; int userid = Int32.Parse(acount); usersTableAdapter adpr = new usersTableAdapter(); var data = adpr.GetDataBy(userid); if (GridView1.Rows.Count < 1) { login_txt.Text = "帐号或密码错误"; login_txt.Visible = true; //return ; //Response.Redirect("login.aspx"); } else { var singledata = data.Single(); int usertype = singledata.use_type; if (usertype == 2) { Response.Redirect("admin.aspx"); } Response.Redirect("success.aspx"); } }
public void AdapterTest() { usersTableAdapter target = new usersTableAdapter(); // TODO: Initialize to an appropriate value SqlCeDataAdapter actual; actual = target.Adapter; Assert.Inconclusive("Verify the correctness of this test method."); }
protected void Button_user_search_Click(object sender, EventArgs e)//搜索单个用户信息 { DetailsView2.Visible = false; int nameid = Int32.Parse(TextBox_nameid_search.Text); usersTableAdapter useradpr = new usersTableAdapter(); Session["nameid"] = nameid; DetailsView3.Visible = true; }
public void GetDataTest() { usersTableAdapter target = new usersTableAdapter(); // TODO: Initialize to an appropriate value AutoWebAgentDBDataSet.usersDataTable expected = null; // TODO: Initialize to an appropriate value AutoWebAgentDBDataSet.usersDataTable actual; actual = target.GetData(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void UpdateTest3() { usersTableAdapter target = new usersTableAdapter(); // TODO: Initialize to an appropriate value AutoWebAgentDBDataSet dataSet = null; // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; actual = target.Update(dataSet); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void ConnectionTest() { usersTableAdapter target = new usersTableAdapter(); // TODO: Initialize to an appropriate value SqlCeConnection expected = null; // TODO: Initialize to an appropriate value SqlCeConnection actual; target.Connection = expected; actual = target.Connection; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void DeleteTest() { usersTableAdapter target = new usersTableAdapter(); // TODO: Initialize to an appropriate value int p1 = 0; // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; actual = target.Delete(p1); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void ClearBeforeFillTest() { usersTableAdapter target = new usersTableAdapter(); // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; target.ClearBeforeFill = expected; actual = target.ClearBeforeFill; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void InsertTest() { usersTableAdapter target = new usersTableAdapter(); // TODO: Initialize to an appropriate value string p1 = string.Empty; // TODO: Initialize to an appropriate value string p2 = string.Empty; // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; actual = target.Insert(p1, p2); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public DAL() { IsInitialized = false; actionAdapter = new actionTableAdapter(); conditionAdapter = new conditionTableAdapter(); elementAdapter = new elementTableAdapter(); recognitionAdapter = new recognitionTableAdapter(); scriptAdapter = new scriptTableAdapter(); stepAdapter = new stepTableAdapter(); usersAdapter = new usersTableAdapter(); websiteAdapter = new websiteTableAdapter(); queries = new QueriesTableAdapter(); validationAdapter = new validationTableAdapter(); DB = new AutoWebAgentDBDataSet(); }
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { string aName = e.Values["username"].ToString(); using (usersTableAdapter aAdapter = new usersTableAdapter()) { usersDataTable aTable; aTable = aAdapter.GetDataByUserName(aName); if (aTable.Rows.Count > 0) { Label11.Text = "Pick Another User Name"; DetailsView1.Rows[0].Cells[1].Controls[0].Focus(); e.Cancel = true; } } }
protected void delete_users_one_Click(object sender, EventArgs e)//删除单个用户 { Button btn = (Button)sender; string id = btn.CommandArgument; int nameid = Int32.Parse(id); usersTableAdapter useradpr = new usersTableAdapter(); try { useradpr.DeleteQuery(nameid); usersGridView.DataBind(); } catch { Label_delete_user.Text = "删除了借阅书籍的用户"; Label_delete_user.Visible = true; } }
public IEnumerable <UserDTO> GetAllUsers() { GWDataSet gw = new GWDataSet(); usersTableAdapter adapter = new usersTableAdapter(); adapter.Fill(gw.users); List <UserDTO> list = new List <UserDTO>(); foreach (DataRow row in gw.users.Rows) { UserDTO user = new UserDTO(); user.FirstName = row["Name"].ToString(); // fill properties list.Add(user); } return(list); }
protected void insert_users_Click(object sender, EventArgs e)//增加用户 { usersTableAdapter adpr = new usersTableAdapter(); int nameid = Int32.Parse(nameid_tx.Text); string name = name_tx.Text; string pwd = password_tx.Text; double wallet = double.Parse(wallet_tx.Text); int use_type = Int32.Parse(usetype_tx.Text); try { adpr.InsertQuery(nameid, name, wallet, pwd, use_type); } /**触发器NO_WALLET**/ /** * CREATE TRIGGER NO_WALLET ON users * FOR INSERT * AS * IF ( * ( * SELECT COUNT(*) FROM inserted * WHERE inserted.wallet<0)>0 * * ) * rollback TRANSACTION; * * SELECT * FROM Sysobjects WHERE xtype = 'TR' **/ catch (Exception) { errorMsg.Text = "余额不能小于0"; errorMsg.Visible = true; } usersGridView.DataBind(); }
protected void btnborrow_Click(object sender, EventArgs e)//借阅书籍按钮 { borrowMsg.Visible = false; Label1.Visible = false; Button btn = (Button)sender; //int row = ((GridViewRow)((Button)sender).NamingContainer).RowIndex; string id = btn.CommandArgument; Session["id"] = id; //获取书籍id int bookid = Int32.Parse(id); int nameid = Int32.Parse(Session["txtname"].ToString()); string time = DateTime.Now.ToString(); int days = 90; string return_time = DateTime.Now.AddDays(days).ToString(); borrowTableAdapter adprbook = new borrowTableAdapter(); book_tableTableAdapter adpr = new book_tableTableAdapter(); usersTableAdapter adpruser = new usersTableAdapter(); var data = adpr.GetDataBy(bookid);//获取剩余书本量 var singledata = data.Single(); int left = singledata.left; var userdata = adpruser.GetDataBy(nameid);//获取余额 var singleuserdate = userdata.Single(); double wallet = singleuserdate.wallet; double cost = days * 0.01; if (left == 0)// 书籍剩余量为0,借阅失败 { Label1.Text = "剩余量为0,无法借阅"; Label1.Visible = true; } else { if (wallet < cost) //余额不足 借阅失败 { Label1.Text = "余额不足"; Label1.Visible = true; } else { try { adprbook.InsertQuery(bookid, nameid, time, 90, return_time); GridView3.Visible = true; left = left - 1; adpr.Updateleft(left, bookid); GridView3.DataBind(); //刷新借阅信息 GridView1.DataBind(); //刷新书籍信息 wallet = wallet - cost; adpruser.walletupdate(wallet, nameid); GridView2.DataBind(); //刷新个人信息 } catch //已经借阅了此书,借阅失败 { Label1.Text = "已经借阅了此书,不能重复借阅"; Label1.Visible = true; GridView3.Visible = true; } } } }
public void usersTableAdapterConstructorTest() { usersTableAdapter target = new usersTableAdapter(); Assert.Inconclusive("TODO: Implement code to verify target"); }