public void BindSearch() { using (BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer()) { if (db.Orders.Count() > 0) { gvOrders.DataSource = (from o in db.Orders where o.Amount.Contains(txtSearch.Text) || o.AmountTotal.Contains(txtSearch.Text) || o.CurrencyFrom.Contains(txtSearch.Text) || o.CurrencyTo.Contains(txtSearch.Text) || o.Date.Contains(txtSearch.Text) select new { o.AmountTotal, o.Amount, o.CurrencyFrom, o.CurrencyTo, o.Date, o.OrderId, o.UserUserId }).ToList(); gvOrders.DataBind(); } } }
protected void btnSave_Click(object sender, EventArgs e) { BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer(); int UserId = Convert.ToInt32(txtUserId.Text); User user = db.Users.First(u => u.UserId == UserId); user.Email = txtEmail.Text; user.FirstName = txtFirstName.Text; user.LastName = txtLastName.Text; user.Password = txtPassword.Text; user.PhoneNumber = txtPhoneNumber.Text; if (rdYes.Checked == true) { user.Admin = "Yes"; } else { user.Admin = "No"; } db.SaveChanges(); BindGrid(); txtConfirmPassword.Text = ""; txtEmail.Text = ""; txtFirstName.Text = ""; txtLastName.Text = ""; txtPassword.Text = ""; txtPhoneNumber.Text = ""; txtSearch.Text = ""; txtUserId.Text = ""; }
public void BindGrid() { using (BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer()) { if (db.Orders.Count() > 0) { gvOrders.DataSource = (from o in db.Orders select new { o.AmountTotal, o.Amount, o.CurrencyFrom, o.CurrencyTo, o.Date, o.OrderId, o.UserUserId }).ToList(); gvOrders.DataBind(); } else { gvOrders.DataSource = null; gvOrders.DataBind(); } } }
public void BindSearch() { using (BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer()) { if (db.Users.Count() > 0) { gvUsers.DataSource = (from u in db.Users where u.FirstName.Contains(txtSearch.Text) || u.Email.Contains(txtSearch.Text) || u.LastName.Contains(txtSearch.Text) || u.PhoneNumber.Contains(txtSearch.Text) || u.Admin.Contains(txtSearch.Text) select new { u.UserId, u.FirstName, u.LastName, u.Email, u.Password, u.Admin, u.PhoneNumber }).ToList(); gvUsers.DataBind(); } } }
public void BindGrid() { using (BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer()) { if (db.Users.Count() > 0) { gvUsers.DataSource = (from u in db.Users select new { u.UserId, u.FirstName, u.LastName, u.Email, u.Password, u.Admin, u.PhoneNumber }).ToList(); gvUsers.DataBind(); } else { gvUsers.DataSource = null; gvUsers.DataBind(); } } }
protected void gvUsers_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Admin") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gvUsers.Rows[index]; int UserId = Convert.ToInt32(gvUsers.DataKeys[index].Value); BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer(); User user = db.Users.First(u => u.UserId == UserId); user.Admin = "Yes"; db.SaveChanges(); } else if (e.CommandName == "Undo") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gvUsers.Rows[index]; int UserId = Convert.ToInt32(gvUsers.DataKeys[index].Value); BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer(); User user = db.Users.First(u => u.UserId == UserId); user.Admin = "No"; db.SaveChanges(); } else if (e.CommandName == "More") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gvUsers.Rows[index]; int UserId = Convert.ToInt32(gvUsers.DataKeys[index].Value); Response.Redirect("UserDetail.aspx?userId=" + UserId); } BindGrid(); }
protected void gvOrders_RowDeleting(object sender, GridViewDeleteEventArgs e) { using (BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer()) { int orderid = Convert.ToInt32(gvOrders.DataKeys[e.RowIndex].Value); Order ord = db.Orders.First(x => x.OrderId == orderid); db.Orders.Remove(ord); db.SaveChanges(); } BindGrid(); }
protected void gvOrders_RowUpdating(object sender, GridViewUpdateEventArgs e) { using (BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer()) { int OrderId = Convert.ToInt32(gvOrders.DataKeys[e.RowIndex].Value); Order ord = db.Orders.First(x => x.OrderId == OrderId); txtOrderId.Text = ord.OrderId.ToString(); txtAmount.Text = ord.Amount; txtTotal.Text = ord.AmountTotal; txtTotal.Text = ord.AmountTotal; ddlFrom.Text = ord.CurrencyFrom; ddlTo.Text = ord.CurrencyTo; } }
protected void btnSave_Click(object sender, EventArgs e) { BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer(); var u = new User(); u.Admin = "No"; u.Email = txtEmail.Text; u.FirstName = txtFirstName.Text; u.LastName = txtLastName.Text; u.Password = txtPassword.Text; u.PhoneNumber = txtPhoneNumber.Text; db.Users.Add(u); db.SaveChanges(); Response.Redirect("LoginPage.aspx"); }
protected void btnLogin_Click(object sender, EventArgs e) { using (var db = new BestTransferMoneyModelContainer()) { var EmailResult = (from em in db.Users where em.Email == txtEmail.Text select em.Email).SingleOrDefault(); var PasswordResult = (from en in db.Users where en.Email == txtEmail.Text select en.Password).SingleOrDefault(); var VerifyAdmin = (from v in db.Users where v.Email == txtEmail.Text select v.Admin).SingleOrDefault(); var VerifyUserId = (from u in db.Users where u.Email == txtEmail.Text select u.UserId).SingleOrDefault(); var VerifyFirstName = (from u in db.Users where u.Email == txtEmail.Text select u.FirstName).SingleOrDefault(); if (EmailResult != txtEmail.Text) { lblEmailValidation.Visible = true; } else if (PasswordResult != txtPassword.Text) { lblPasswordValidation.Visible = true; } else { Session["Email"] = txtEmail.Text; Session["Admin"] = VerifyAdmin; Session["UserId"] = VerifyUserId; Session["FirstName"] = VerifyFirstName; Response.Redirect("Default.aspx?user=" + txtEmail.Text); } } }
protected void btnSave_Click(object sender, EventArgs e) { BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer(); int OrderId = Convert.ToInt32(txtOrderId.Text); Order ord = db.Orders.First(u => u.OrderId == OrderId); ord.AmountTotal = txtTotal.Text; ord.CurrencyFrom = ddlFrom.Text; ord.CurrencyTo = ddlTo.Text; ord.Amount = txtAmount.Text; ord.AmountTotal = txtTotal.Text; db.SaveChanges(); BindGrid(); txtAmount.Text = ""; txtTotal.Text = ""; txtTotal.Text = ""; ddlFrom.Text = "FROM"; ddlTo.Text = "TO"; lblCalculation.Visible = false; }
protected void btnSave_Click(object sender, EventArgs e) { BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer(); var o = new Order(); var user = Session["UserId"]; // var email = Session["Email"]; o.AmountTotal = txtTotal.Text; o.CurrencyFrom = ddlFrom.Text; o.CurrencyTo = ddlTo.Text; o.Amount = txtAmount.Text; o.Date = lblDate.Text; o.UserUserId = Convert.ToInt32(user); db.Orders.Add(o); db.SaveChanges(); txtAmount.Text = ""; txtTotal.Text = ""; ddlFrom.Text = "FROM"; ddlTo.Text = "TO"; lblCalculation.Visible = false; }
protected void gvUsers_RowUpdating(object sender, GridViewUpdateEventArgs e) { using (BestTransferMoneyModelContainer db = new BestTransferMoneyModelContainer()) { int UserId = Convert.ToInt32(gvUsers.DataKeys[e.RowIndex].Value); User user = db.Users.First(x => x.UserId == UserId); txtUserId.Text = user.UserId.ToString(); txtEmail.Text = user.Email; txtFirstName.Text = user.FirstName; txtLastName.Text = user.LastName; txtPhoneNumber.Text = user.PhoneNumber; txtPassword.Text = user.Password; txtConfirmPassword.Text = user.Password; if (user.Admin == "Yes") { rdYes.Checked = true; } else { rdNo.Checked = true; } } }