Skip to content

Commit

Permalink
Project
Browse files Browse the repository at this point in the history
  • Loading branch information
IrinaSendetskaya committed Mar 13, 2018
1 parent 1e46cee commit 9862d72
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/by/it/sendetskaya/project/java/DAO/CreateNewSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ public static void fillDataRoles () throws SQLException {

sql=String.format("INSERT INTO sendetskaya.roles (Role) VALUES ('Пользователь');");
statement.executeUpdate(sql);

sql=String.format("INSERT INTO sendetskaya.roles (Role) VALUES ('Черный список');");
statement.executeUpdate(sql);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public List<Good> getAll(String where) throws SQLException {
try(Connection connection= ConnectionCreator.getConnection();
Statement statement=connection.createStatement()
) {
String sql=String.format("SELECT * FROM goods "+where+ ";");
String sql=("SELECT * FROM goods "+where+ ";");

ResultSet resultSet=statement.executeQuery(sql);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ Action execute(HttpServletRequest req, HttpServletResponse resp) throws Exceptio
if (goods.size()<1)
req.setAttribute(Msg.ERROR, "Ваша корзина пуста!");

Iterator<Double> iterator=sumList.iterator();
Iterator<Basket> iterator=baskets.iterator();
while (iterator.hasNext())
{
sumReady+=iterator.next();
sumReady+=iterator.next().getSum();
}

if (req.getParameter("ready") != null) {
req.setAttribute(Msg.ERROR, "Ваш заказ принят, сумма к оплате: "+sumReady);
String sumOutput=String.format("Ваш заказ принят, сумма к оплате: %5.2f рублей", sumReady);
req.setAttribute(Msg.MESSAGE, sumOutput);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.text.Format;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -31,11 +32,11 @@ Action execute(HttpServletRequest req, HttpServletResponse resp) throws Exceptio
String nameSearch=FormUtil.getString(req,"searchInput", "[\\wА-Яа-я]+");

//выводит список товаро только по части слова Поиска
goods=DAO.getDAO().goodDAO.getAll(" WHERE Name LIKE '%"+nameSearch+"%'");
goods=DAO.getDAO().goodDAO.getAll((" WHERE Name LIKE '%"+nameSearch+"%'"));

req.setAttribute("goods",goods);

req.setAttribute(Msg.ERROR, "товар по Вашему поиску найден!");
req.setAttribute(Msg.MESSAGE, "товар по Вашему поиску найден!");
return null;

}
Expand All @@ -48,7 +49,7 @@ Action execute(HttpServletRequest req, HttpServletResponse resp) throws Exceptio


//если нажата кнопка "В корзину"
if (req.getParameter("Update")!= null ) {
if (req.getParameter("Update")!= null && buyer.getFk_roles()!=3) {
int idGood = FormUtil.getInt(req, "ID");
double price=FormUtil.getDouble(req,"Price");
String name=goods.get(0).getName();
Expand All @@ -62,7 +63,7 @@ Action execute(HttpServletRequest req, HttpServletResponse resp) throws Exceptio
Basket basket=new Basket(id,quantity,sum,fk_buyers,fk_goods);
DAO.getDAO().basketDAO.create(basket);

req.setAttribute(Msg.ERROR, "товар " + name + " добавлен в корзину");
req.setAttribute(Msg.MESSAGE, "товар " + name + " добавлен в корзину");
return null;


Expand Down
2 changes: 2 additions & 0 deletions src/by/it/sendetskaya/project/webapp/include/begin-html.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@
</c:when>
<c:otherwise>

<c:if test="${buyer.fk_roles!=3}">
<li class="nav-item active">
<a class="nav-link" href="do?command=Profile">Личный кабинет <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="do?command=CreateBasket">Корзина<span class="sr-only">(current)</span></a>
</li>
</c:if>
<li class="nav-item">
<a class="nav-link" href="do?command=Logout">Выйти <span class="sr-only">(current)</span></a>
</li>
Expand Down
2 changes: 2 additions & 0 deletions src/by/it/sendetskaya/project/webapp/include/end-html.jsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Error: <b> ${error}</b>
<br>
Cmd: <b>${message}</b>

</div> <!---container-->

Expand Down
2 changes: 2 additions & 0 deletions src/by/it/sendetskaya/project/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@

</div>

<c:if test="${buyer.fk_roles!=3}">
<div class="col-md-1">
<button id="Update" value="Update" name="Update" class="btn btn-success">
В корзину
</button>
</div>
</c:if>
</div>

</form>
Expand Down

0 comments on commit 9862d72

Please sign in to comment.