public ActionResult Delete() { // Create New Objects. DBStuff dal = new DBStuff(); Login myUser = new Login(); LoginUsers logU = new LoginUsers(); // The list of Orders from Db. List <Login> objCars = dal.CustomersLog.ToList <Login>(); // Id Customer to delete the order. myUser.ID = Request.Form["GetIDtext2"].ToString(); // find the product we are looking for by ProductId. foreach (Login ob in objCars) { if (myUser.ID == ob.ID) { // remove the product we want form the list. dal.CustomersLog.Remove(ob); dal.SaveChanges(); } } return(View("DeleteOrder")); }
public ActionResult UpdateOrder() { LoginUsers log = new LoginUsers(); Login ObjOrder = new Login(); DBStuff dal = new DBStuff(); ObjOrder.ID = Request.Form["GetIDtext"].ToString(); ObjOrder.StartDate = Request.Form["startDate1"].ToString(); ObjOrder.EndDate = Request.Form["endDate1"].ToString(); ObjOrder.CarSelect = "none"; Login np1 = (from x in dal.CustomersLog where x.ID == ObjOrder.ID select x).ToList <Login>()[0]; if (ModelState.IsValid) { np1.StartDate = ObjOrder.StartDate; np1.EndDate = ObjOrder.EndDate; dal.SaveChanges(); } ObjOrder = np1; return(RedirectToAction("SelectVehicle", ObjOrder)); }
public ActionResult Submit(MyOrder log) { if (ModelState.IsValid) { DBStuff dal = new DBStuff(); List <MyOrder> objOrdersI = dal.OrdersLog.ToList <MyOrder>(); List <Login> objCars = dal.CustomersLog.ToList <Login>(); // check if the username and the password are in the DB. foreach (MyOrder ob1 in objOrdersI) { // if they are in the Db go to OrdersPage if (log.Username == ob1.Username && log.Password == ob1.Password) { foreach (Login ob2 in objCars) { if (log.Password == ob2.OrderID) { TempData["MyOrder2"] = log.Password; return(RedirectToAction("CustomerOrder", TempData["MyOrder2"])); } } } } } return(View("LoginCustomer")); }
public ActionResult AddOrder() { DBStuff dal = new DBStuff(); MyOrder myUser = new MyOrder(); List <MyOrder> objOrdersI = dal.OrdersLog.ToList <MyOrder>(); // Take the values from the TextBox of the user. myUser.Username = Request.Form["order.Username1"].ToString(); myUser.Password = Request.Form["order.Password1"].ToString(); if (ModelState.IsValid) { // check if the username and the password are in the DB. foreach (MyOrder ob1 in objOrdersI) { // if they are in the Db go to OrdersPage if (myUser.Password == ob1.Password || myUser.Username == ob1.Username) { TempData["User"] = myUser; return(RedirectToAction("NewCarOrder", TempData["User"])); } } } return(View("NewOrderUser")); }
protected void btnAddBill_Click(object sender, EventArgs e) { if (txtComanyName.Text.Length.Equals(0) || txtDueDate.Text.Length.Equals(0)) { lblErrorMessage.Text = "Comanyname or Duedate can't be blank."; return; } DBStuff myDBStuff = new DBStuff(); try { myDBStuff.AddBill(txtComanyName.Text, txtDueDate.Text, txtAmount.Text); } catch(Exception ex) { lblAdded.Text = "Something happen. You broke it. Error is " + ex.Message; return; } lblAdded.Text = "Bill add for " + txtComanyName.Text + " and Due Date is " + txtDueDate.Text; txtAmount.Text = ""; txtDueDate.Text = ""; txtComanyName.Text = ""; }
public ActionResult OrderComplete() { DBStuff dal = new DBStuff(); List <Cars> objCars = dal.CarsLog.ToList <Cars>(); CarsInStock mcar = new CarsInStock(); Login ObjOrder = new Login(); if (TempData.ContainsKey("Student")) { //If so access it here ObjOrder = TempData["Student"] as Login; //find Button clicked. foreach (Cars ob1 in objCars) { if (Request.Form[ob1.CarID] != null) { Login np1 = (from x in dal.CustomersLog where x.ID == ObjOrder.ID select x).ToList <Login>()[0]; ObjOrder.CarSelect = ob1.CarType; np1.CarSelect = ob1.CarType; dal.SaveChanges(); } } } return(View()); }
private void tsbTestConnection_Click(object sender, EventArgs e) { string ConnectionString = string.Empty; if (cIntegratedSecurity.Checked) { ConnectionString = "Data Source=" + tServerName.Text + ";Integrated Security=True"; } else { ConnectionString = "Data Source=" + tServerName.Text + ";User ID=" + tUserName.Text + ";Password="******"Connection successful", "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Connection failed", "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch { } }
public ActionResult getCarsByJson() { DBStuff dal = new DBStuff(); Thread.Sleep(2000); List <Cars> objCars = dal.CarsLog.ToList <Cars>(); return(Json(objCars, JsonRequestBehavior.AllowGet)); }
public ActionResult getOrdersByJson() { DBStuff dal = new DBStuff(); Thread.Sleep(2000); List <Login> objOrder = dal.CustomersLog.ToList <Login>(); return(Json(objOrder, JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { DBStuff dal = new DBStuff(); List <Cars> objCars = dal.CarsLog.ToList <Cars>(); CarsInStock mcar = new CarsInStock(); mcar.car = new Cars(); mcar.cars = objCars; return(View(mcar)); }
public ActionResult CustomerOrder() { DBStuff dal = new DBStuff(); List <Login> objCars = dal.CustomersLog.ToList <Login>(); LoginUsers logu = new LoginUsers(); logu.user = new Login(); logu.users = objCars; return(View(logu)); }
public ActionResult SelectVehicle(Login ObjOrder) { DBStuff dal = new DBStuff(); List <Cars> objCars = dal.CarsLog.ToList <Cars>(); CarsInStock mcar = new CarsInStock(); TempData["Student"] = ObjOrder; mcar.car = new Cars(); mcar.cars = objCars; return(View(mcar)); }
private static Person SafeGetPerson(int personId) { try { return(DBStuff.GetPersonById(personId)); } catch (Exception e) { LogException(e); return(null); } }
public ActionResult SubmitOrder() { LoginUsers log = new LoginUsers(); Login ObjOrder = new Login(); ObjOrder.Visa = Request.Form["user.Visa"].ToString(); ObjOrder.ID = Request.Form["user.OrderID2"].ToString(); ObjOrder.OrderID = Request.Form["user.OrderID"].ToString(); ObjOrder.StartDate = Request.Form["startDate1"].ToString(); ObjOrder.EndDate = Request.Form["endDate1"].ToString(); ObjOrder.CarSelect = "none"; if (ModelState.IsValid) { DBStuff dal = new DBStuff(); // Save in the DB dal.CustomersLog.Add(ObjOrder); dal.SaveChanges(); return(RedirectToAction("SelectVehicle", ObjOrder)); } return(View("NewCarOrder")); }
protected void Page_Load(object sender, EventArgs e) { ID = Request.QueryString["PaidID"]; myDB = new DBStuff(); if (!Page.IsPostBack) { if (!Request.QueryString.Count.Equals(0)) { // Create and fill a DataSet. DataSet ds = myDB.GetBill(ID); foreach (DataRow dr in ds.Tables[0].Rows) { txtAmount.Text = dr["Amount"].ToString(); txtCompany.Text = dr["Company"].ToString(); txtDueDate.Text = dr["DueDate"].ToString().Split(' ')[0]; } } else Response.Redirect("default.aspx"); } }
private static IResult <Person> SafeGetPerson(int personId) { return(Result.Wrap(() => DBStuff.GetPersonById(personId))); }
protected void Page_Load(object sender, EventArgs e) { DBStuff myDB = new DBStuff(); DataSet ds = null; if (!Request.QueryString.Count.Equals(0)) { string ID = Request.QueryString["PaidID"]; if (Request.QueryString.AllKeys.Contains("View")) { if (Request.QueryString["View"].Equals("All")) { lblShowDates.Text = "Showing all bills."; ds = myDB.GetAllBills(); pView.InnerHtml = "<a href=Default.aspx>View Only 30 days</a>"; } } if (Request.QueryString.AllKeys.Contains("Call")) { string CallFunction = Request.QueryString["Call"].ToString(); if(CallFunction.Equals("Delete")) myDB.DeleteBill(ID); lblShowDates.Text = "Bills from " + DateTime.Now.Date.ToString().Split(' ')[0] + " and " + DateTime.Now.Date.AddDays(30).ToString().Split(' ')[0]; ds = myDB.GetBillsDataRange(DateTime.Now.Date, DateTime.Now.Date.AddDays(30)); pView.InnerHtml = "<a href=Default.aspx?View=All>View All</a>"; } if (Request.QueryString.AllKeys.Contains("Paid")) { string Paid = string.Empty; string DatePaid = null; if (Request.QueryString["Paid"].ToString().ToLower().Equals("yes")) Paid = "No"; else if (Request.QueryString["Paid"].ToString().ToLower().Equals("no")) { Paid = "Yes"; DatePaid = DateTime.Now.ToShortDateString(); } myDB.UpDatePaid(ID, Paid, DatePaid); lblShowDates.Text = "Bills from " + DateTime.Now.Date.ToString().Split(' ')[0] + " and " + DateTime.Now.Date.AddDays(30).ToString().Split(' ')[0]; ds = myDB.GetBillsDataRange(DateTime.Now.Date, DateTime.Now.Date.AddDays(30)); pView.InnerHtml = "<a href=Default.aspx?View=All>View All</a>"; } } else { lblShowDates.Text = "Bills from " + DateTime.Now.Date.ToString().Split(' ')[0] + " and " + DateTime.Now.Date.AddDays(30).ToString().Split(' ')[0]; ds = myDB.GetBillsDataRange(DateTime.Now.Date, DateTime.Now.Date.AddDays(30)); pView.InnerHtml = "<a href=Default.aspx?View=All>View All</a>"; } if(!(ds == null)) { StringBuilder BillsHTML = new StringBuilder(); double TotalOfBills = 0; BillsHTML.Append("<table border=1>"); foreach (DataRow dr in ds.Tables[0].Rows) { BillsHTML.Append("<tr>"); if (dr["Paid"].ToString().ToLower().Equals("yes")) BillsHTML.Append("<del>"); BillsHTML.Append("<td>" + dr["Company"] + "</td>"); if (dr["Paid"].ToString().ToLower().Equals("yes")) BillsHTML.Append("</del>"); BillsHTML.Append("<td>" + "$" + dr["Amount"] + "</td> "); TotalOfBills += (double)dr["Amount"]; BillsHTML.Append("<td>" + dr["DueDate"].ToString().Split(' ')[0] + "</td>"); if (dr["Paid"].ToString().ToLower().Equals("yes")) { BillsHTML.Append("<td><a href=default.aspx?PaidID=" + dr["IndexNumber"] + "&Paid=" + dr["Paid"] + ">Paid on " + dr["DatePaid"].ToString().Split(' ')[0] + "</a></td>"); } else BillsHTML.Append("<td><a href=default.aspx?PaidID=" + dr["IndexNumber"] + "&Paid=" + dr["Paid"] + ">Not Paid</a></td>"); BillsHTML.Append("<td> <a href=edit.aspx?PaidID=" + dr["IndexNumber"] + ">Edit</a></td>"); BillsHTML.Append("<td> <a href=default.aspx?PaidID=" + dr["IndexNumber"] + "&Call=Delete>Delete</a></td>"); BillsHTML.Append("</tr>"); } BillsHTML.Append("</table>"); BillsHTML.Append("<br/>"); BillsHTML.Append("<b>Total Due: </b> $" + TotalOfBills); mydiv.InnerHtml = BillsHTML.ToString(); } }