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 = ""; }
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 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 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; }