// GET: /Shipper/Edit
        public ActionResult Edit(string username)
        {

            if ( string.IsNullOrEmpty(username))
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            if ( string.IsNullOrEmpty(username))
            {
                return HttpNotFound();
            }
            Debug.WriteLine("in controller " + username);
            if (username == null)
            {
                Debug.WriteLine("null");
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            if (username == null)
            {
                Debug.WriteLine("not found");
                return HttpNotFound();
            }
            Shipper s = new Shipper(username);
             
            return View(s);
        }
        public ActionResult Register(Shipper s)
        {
            if (ModelState.IsValid)
            {
                s.insertShipper(s);
            }
            else
            {

                return View(s);
            }
            return RedirectToAction("Details");
        }
 public ActionResult Edit(Shipper r, string command)
 {
     if (command.Equals("Update"))
     {
         if (ModelState.IsValid)
         {
             r.updateShipper(r);
         }
         else
         {
             return View(r);
         }
     }
     else
     {
         r.deleteShipper(r.username);
     }
     return RedirectToAction("Details");
 }
        public ActionResult Register(Shipper s)
        {
            if (s == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            if (s == null)
            {
                return HttpNotFound();
            }

            if (ModelState.IsValid)
            {
                s.insertShipper(s);
            }
            else
            {

                return View(s);
            }
            return RedirectToAction("Details");
        }
Exemplo n.º 5
0
        public void updateShipper(Shipper s)
        {
            using (MySqlConnection con = new MySqlConnection(con_str))
            {
                con.Open();
                using (MySqlCommand cmd = new MySqlCommand("updateShiper", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    //params for insert into username
                    cmd.Parameters.AddWithValue("@_username", s.username);
                    cmd.Parameters.AddWithValue("@password", Encryption.Encrypt(s.password));
                    cmd.Parameters.AddWithValue("@accountType", s.acctype);

                    //params for insert into address
                    cmd.Parameters.AddWithValue("@firstLine", s.firstLine);
                    if (s.secondLine != null)
                    {
                        cmd.Parameters.AddWithValue("@secondLine", s.secondLine);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@secondLine", null);
                    }
                    cmd.Parameters.AddWithValue("@town", s.town);
                    cmd.Parameters.AddWithValue("@postcode", s.postcode);
                    cmd.Parameters.AddWithValue("@region", s.region);
                    cmd.Parameters.AddWithValue("@country", s.country);

                    //params for insert into bankDetails
                    cmd.Parameters.AddWithValue("@sortCode", s.sortCode);
                    cmd.Parameters.AddWithValue("@accountNumber", s.accountNumber);

                    //params for insert into contact
                    cmd.Parameters.AddWithValue("@title", s.title.ToString());
                    cmd.Parameters.AddWithValue("@forename", s.forename);
                    cmd.Parameters.AddWithValue("@surname", s.surname);
                    cmd.Parameters.AddWithValue("@firstNumber", s.firstNumber);
                    if (s.secondaryNumber != null)
                    {
                        cmd.Parameters.AddWithValue("@secondaryNumber", s.secondaryNumber);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@secondaryNumber", null);
                    }
                    cmd.Parameters.AddWithValue("@email", s.email);
                    if (s.fax != null)
                    {
                        cmd.Parameters.AddWithValue("@fax", s.fax);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@fax", null);
                    }

                    //params for insert into shippers
                    cmd.Parameters.AddWithValue("@companyName", s.companyName);
                    cmd.Parameters.AddWithValue("@_ukRate", s.discount);
                    cmd.Parameters.AddWithValue("@intRate", s.internationalRate);

                    //params for insert into paymentdetails
                    cmd.Parameters.AddWithValue("@creditCardType", s.cardType.ToString());
                    cmd.Parameters.AddWithValue("@fName", s.cardForename);
                    cmd.Parameters.AddWithValue("@lName", s.cardSurname);
                    cmd.Parameters.AddWithValue("@cardNumber", Encryption.Encrypt(s.cardNo));
                    cmd.Parameters.AddWithValue("@startDate", s.startDate);
                    cmd.Parameters.AddWithValue("@expiryDate", s.endDate);
                    cmd.Parameters.AddWithValue("@issueNumber", s.issueNo);

                    cmd.ExecuteNonQuery();

                    con.Close();
                }
            }
        }
Exemplo n.º 6
0
        public void updateShipper(Shipper s)
        {
            using (MySqlConnection con = new MySqlConnection(con_str))
            {
                con.Open();
                using (MySqlCommand cmd = new MySqlCommand("updateShiper", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    //params for insert into username
                    cmd.Parameters.AddWithValue("@_username", s.username);
                    cmd.Parameters.AddWithValue("@password", Encryption.Encrypt(s.password));
                    cmd.Parameters.AddWithValue("@accountType", s.acctype);

                    //params for insert into address
                    cmd.Parameters.AddWithValue("@firstLine", s.firstLine);
                    if (s.secondLine != null)
                    {
                        cmd.Parameters.AddWithValue("@secondLine", s.secondLine);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@secondLine", null);
                    }
                    cmd.Parameters.AddWithValue("@town", s.town);
                    cmd.Parameters.AddWithValue("@postcode", s.postcode);
                    cmd.Parameters.AddWithValue("@region", s.region);
                    cmd.Parameters.AddWithValue("@country", s.country);

                    //params for insert into bankDetails
                    cmd.Parameters.AddWithValue("@sortCode", s.sortCode);
                    cmd.Parameters.AddWithValue("@accountNumber", s.accountNumber);

                    //params for insert into contact
                    cmd.Parameters.AddWithValue("@title", s.title.ToString());
                    cmd.Parameters.AddWithValue("@forename", s.forename);
                    cmd.Parameters.AddWithValue("@surname", s.surname);
                    cmd.Parameters.AddWithValue("@firstNumber", s.firstNumber);
                    if (s.secondaryNumber != null)
                    {
                        cmd.Parameters.AddWithValue("@secondaryNumber", s.secondaryNumber);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@secondaryNumber", null);
                    }
                    cmd.Parameters.AddWithValue("@email", s.email);
                    if (s.fax != null)
                    {
                        cmd.Parameters.AddWithValue("@fax", s.fax);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@fax", null);
                    }

                    //params for insert into shippers
                    cmd.Parameters.AddWithValue("@companyName", s.companyName);
                    cmd.Parameters.AddWithValue("@_ukRate", s.discount);
                    cmd.Parameters.AddWithValue("@intRate", s.internationalRate);

                    //params for insert into paymentdetails
                    cmd.Parameters.AddWithValue("@creditCardType", s.cardType.ToString());
                    cmd.Parameters.AddWithValue("@fName", s.cardForename);
                    cmd.Parameters.AddWithValue("@lName", s.cardSurname);
                    cmd.Parameters.AddWithValue("@cardNumber", Encryption.Encrypt(s.cardNo));
                    cmd.Parameters.AddWithValue("@startDate", s.startDate);
                    cmd.Parameters.AddWithValue("@expiryDate", s.endDate);
                    cmd.Parameters.AddWithValue("@issueNumber", s.issueNo);

                    cmd.ExecuteNonQuery();

                    con.Close();
                }
            }
        }
        public ActionResult Edit(Shipper r, string command)
        {
            if (r == null || string.IsNullOrEmpty(command))
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            if (r == null || string.IsNullOrEmpty(command))
            {
                return HttpNotFound();
            }

            if (command.Equals("Update"))
            {
                if (ModelState.IsValid)
                {
                    r.updateShipper(r);
                }
                else
                {
                    return View(r);
                }
            }
            else
            {
                r.deleteShipper(r.username);
            }
            return RedirectToAction("Details");
        }