/// <summary> /// Add's specifing text based on whether the order was just ordered, sent or arrived. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvOrdersOrdered_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > -1) { OrderOrdered orderOrdered = (OrderOrdered)e.Row.DataItem; e.Row.Cells[7].Text = orderOrdered.DateOrderOrdered.ToShortDateString(); if (orderOrdered.DateOrderSent == DateTime.MinValue) { e.Row.Cells[8].Text = "Not sent."; e.Row.Cells[9].Text = "Not sent or arrived."; } else if (orderOrdered.DateOrderArrived == DateTime.MinValue) { e.Row.Cells[8].Text = orderOrdered.DateOrderSent.ToShortDateString(); e.Row.Cells[9].Text = "Not arrived."; e.Row.Cells[10].Text = "Order sent succesfully!"; } else { e.Row.Cells[8].Text = orderOrdered.DateOrderSent.ToShortDateString(); e.Row.Cells[9].Text = orderOrdered.DateOrderArrived.ToShortDateString(); e.Row.Cells[10].Text = "Order sent succesfully!"; } } }
/// <summary> /// Not working /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvOrdersOrdered_RowCommand(object sender, GridViewCommandEventArgs e) { int rowNum = int.Parse(e.CommandArgument.ToString()); int index = rowNum + gvOrdersOrdered.PageSize * gvOrdersOrdered.PageIndex; List <OrderOrdered> dataSource = null; ordersToView = (List <OrderOrdered>)Session["ordersToView"]; if (ordersToView == null) { dataSource = (List <OrderOrdered>)Session["allOrdersOrdered"]; } else { dataSource = ordersToView; } orderToConfirmOrDeny = dataSource[index]; Session["OrderToConfirmOrDeny"] = orderToConfirmOrDeny; pnlConfirmOrDeny.Visible = true; lblOrderToConfirmOrDeny.Text = orderToConfirmOrDeny.ToString(); //if (!orderToConfirmOrDeny.ConfirmOrder()) ConfirmSentError.Visible = true; //else //{ // ConfirmSentError.Visible = false; // if (ordersFromGivenCompany == null) // { // allOrdersOrdered = ((User)Session["User"]).AllOrdersOrdered(); // gvOrdersOrdered.DataSource = allOrdersOrdered; // } // else // { // gvOrdersOrdered.DataSource = ordersFromGivenCompany; // } // gvOrdersOrdered.DataBind(); //} }
protected void gvPreviousOrders_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > -1) { OrderOrdered orderOrdered = (OrderOrdered)e.Row.DataItem; e.Row.Cells[5].Text = orderOrdered.DateOrderOrdered.ToShortDateString(); if (orderOrdered.DateOrderSent == DateTime.MinValue) { e.Row.Cells[6].Text = "Not sent"; e.Row.Cells[7].Text = "Not arrived"; e.Row.Cells[8].Text = "not arrived."; } else if (orderOrdered.DateOrderArrived == DateTime.MinValue) { e.Row.Cells[6].Text = orderOrdered.DateOrderSent.ToShortDateString(); e.Row.Cells[7].Text = "Not arrived"; } else { e.Row.Cells[6].Text = orderOrdered.DateOrderSent.ToShortDateString(); e.Row.Cells[7].Text = orderOrdered.DateOrderArrived.ToShortDateString(); e.Row.Cells[8].Text = "Order arrived, no need to confirm"; } } }
protected void btnConfirmOrDeny_Click(object sender, EventArgs e) { string commandArgument = ((Button)sender).CommandArgument; orderToConfirmOrDeny = (OrderOrdered)Session["OrderToConfirmOrDeny"]; if (orderToConfirmOrDeny == null) { lblError.Text = "An error has accoured. Perhaps you waited to long to click the button? Try pressing the button in the gridview again."; lblGeneralSuccess.Text = ""; btnConfirmSent.Visible = false; btnDenySending.Visible = false; } else if (commandArgument == btnConfirmSent.CommandArgument) { bool flag = orderToConfirmOrDeny.ConfirmOrder(); if (!flag) { lblError.Text = "An error has accoured. Please try again at a later time."; lblGeneralSuccess.Text = ""; } else { lblGeneralSuccess.Text = "Confirmed order was sent successfully!"; allOrdersOrdered = ((User)Session["User"]).AllOrdersOrdered(); Session["allOrdersOrdered"] = allOrdersOrdered; gvOrdersOrdered.DataSource = allOrdersOrdered; gvOrdersOrdered.DataBind(); lblError.Text = ""; } } else //if (commandArgument == btnDenySending.CommandArgument) commented because currently unessesery, if I were to add more buttons then it would be neccesery. { if (!orderToConfirmOrDeny.DeleteOrder()) { lblError.Text = "An error has accoured. Please try again at a later date."; lblGeneralSuccess.Text = ""; } else { lblGeneralSuccess.Text = "Order deleted succussfully!"; allOrdersOrdered = ((User)Session["User"]).AllOrdersOrdered(); if (allOrdersOrdered != null) { Session["allOrdersOrdered"] = allOrdersOrdered; gvOrdersOrdered.DataSource = allOrdersOrdered; gvOrdersOrdered.DataBind(); } else { gvOrdersOrdered.Visible = false; lblError.Text = "It seems you have no orders ordered from you."; lblError.Visible = true; } lblError.Text = ""; } } }
private void LoadPNLGeneralStatistics(List <User> allNonAdmins) { int numOfFarmers, numOfCompanys; numOfFarmers = BL.General.NumOfUserType(allNonAdmins, 2);//A farmers user type is 2. numOfCompanys = allNonAdmins.Count - numOfFarmers; lblNumOfUsers.Text = $"There are currently {numOfFarmers} registered farmers and {numOfCompanys} registered companys."; List <OrderOrdered> allOrdersOrdered = BL.General.AllOrdersOrdered(); double moneyExchanged = BL.General.MoneyExchangedInOrdersOrdered(allOrdersOrdered); int ordersSentNotArrived = BL.General.NumOfOrdersOnTheirWayInOrdersOrdered(allOrdersOrdered); OrderOrdered latestOrderOrdered = BL.General.LatestOrderInOrdersOrdered(allOrdersOrdered); lblMoneyExchanged.Text = $"{moneyExchanged}$ have been exchanged so far between farmers and companys."; lblNumOfOrdersOnTheirWay.Text = $"{ordersSentNotArrived} orders have been sent but have not yet arrived."; lblLatestOrder.Text = $"The latest order to be ordered is: {latestOrderOrdered.ToString()}"; }