예제 #1
0
 public void CreateFieldListEntry(FieldListModel model)
 {
     DbConnection.Open();
     MySqlCommand command = DbConnection.CreateCommand();
     command.CommandText = "INSERT INTO fieldlist (username,fieldname) values(@username,@fieldname)";
     command.Parameters.AddWithValue("@username", model.UserName);
     command.Parameters.AddWithValue("@fieldname", model.FieldName);
     command.ExecuteNonQuery();
     DbConnection.Close();
 }
예제 #2
0
        public void CreateFieldListEntry(FieldListModel model)
        {
            DbConnection.Open();
            MySqlCommand command = DbConnection.CreateCommand();

            command.CommandText = "INSERT INTO fieldlist (username,fieldname) values(@username,@fieldname)";
            command.Parameters.AddWithValue("@username", model.UserName);
            command.Parameters.AddWithValue("@fieldname", model.FieldName);
            command.ExecuteNonQuery();
            DbConnection.Close();
        }
예제 #3
0
        //  create a new bidder instance
        public ActionResult registerNewBidder()
        {
            if (Request.HttpMethod.Equals("POST"))
            {
                BidderModel newBidder = new BidderModel()
                {
                    Name = Request.Form["name"],    //  take data from HTML form
                    Address = Request.Form["address"],
                    tpNo = Request.Form["telephoneNo"],
                    userName = Request.Form["username"],
                    password = Request.Form["password"]
                };
                    HttpPostedFileBase file = Request.Files["picture"];

                if (file != null && file.ContentLength > 0) //  upload file
                {
                    System.IO.Stream fileStream = file.InputStream;
                    byte[] data= new byte[file.ContentLength];
                    fileStream.Read(data, 0, data.Length);
                    fileStream.Close();
                    newBidder.ProfilePic= data;
                }

                BidderModel existing = DBContext.GetInstance().FindOneInBidder("username", newBidder.userName);
                if (existing == null)   //  see weather this this user is already existing.
                {
                    DBContext.GetInstance().CreateBidder(newBidder);    // create db entry

                    if (Request.Form["chq1"] != null && Request.Form["chq1"] == "on")
                    {
                        FieldListModel field = new FieldListModel();    // registered fields
                        field.FieldName = "canteens";
                        field.UserName = newBidder.userName;
                        DBContext.GetInstance().CreateFieldListEntry(field);
                    }
                    if (Request.Form["chq2"] != null && Request.Form["chq2"] == "on")
                    {
                        FieldListModel field = new FieldListModel();
                        field.FieldName = "cleaning services";
                        field.UserName = newBidder.userName;
                        DBContext.GetInstance().CreateFieldListEntry(field);
                    }
                    if (Request.Form["chq3"] != null && Request.Form["chq3"] == "on")
                    {
                        FieldListModel field = new FieldListModel();
                        field.FieldName = "construction";
                        field.UserName = newBidder.userName;
                        DBContext.GetInstance().CreateFieldListEntry(field);
                    }
                    if (Request.Form["chq4"] != null && Request.Form["chq4"] == "on")
                    {
                        FieldListModel field = new FieldListModel();
                        field.FieldName = "delivery services";
                        field.UserName = newBidder.userName;
                        DBContext.GetInstance().CreateFieldListEntry(field);
                    }
                    if (Request.Form["chq5"] != null && Request.Form["chq5"] == "on")
                    {
                        FieldListModel field = new FieldListModel();
                        field.FieldName = "security services";
                        field.UserName = newBidder.userName;
                        DBContext.GetInstance().CreateFieldListEntry(field);
                    }
                    if (Request.Form["chq6"] != null && Request.Form["chq6"] == "on")
                    {
                        FieldListModel field = new FieldListModel();
                        field.FieldName = "vehicles";
                        field.UserName = newBidder.userName;
                        DBContext.GetInstance().CreateFieldListEntry(field);
                    }

                }
                else
                {
                    ViewData["success"] = 0;
                    ViewData["hasError"] = 1;
                    ViewData["errorMsg"] = "Username already exists";
                }
                return RedirectToAction("Bidderlogin", "Bidder");
            }
            return View();
        }