private Control getEditButton(Order current_order) { Control retControl = null; if (Security.IsAuthorized(getUserID(), PwasObject.Order, PwasAction.Update, PwasScope.All) && (current_order.Status.statusId == OrderConstants.ORDER_STATUS_CREATED || current_order.Status.statusId == OrderConstants.ORDER_STATUS_PAID)) { ImageButton editButton = new ImageButton(); editButton.ID = current_order.orderID + "e"; editButton.CommandArgument = current_order.orderID.ToString(); editButton.ImageUrl = "/images/edit.gif"; editButton.Command += new CommandEventHandler(func_Edit); retControl = editButton; } else if (Security.IsAuthorized(getUserID(), PwasObject.Order, PwasAction.Update, PwasScope.Self) && current_order.Status.statusId == OrderConstants.ORDER_STATUS_CREATED && OrderUtilities.isMyOrder(current_order.orderID, getUserID())) { ImageButton editButton = new ImageButton(); editButton.ID = current_order.orderID + "e"; editButton.CommandArgument = current_order.orderID.ToString(); editButton.ImageUrl = "/images/edit.gif"; editButton.Command += new CommandEventHandler(func_Edit); retControl = editButton; } else { Image image = new Image(); image.ImageUrl = "/images/edit_gray.gif"; retControl = image; } return(retControl); }
private Control getViewButton(Order current_order) { Control retControl = null; if (Security.IsAuthorized(getUserID(), PwasObject.Order, PwasAction.Update, PwasScope.All)) { ImageButton viewButton = new ImageButton(); viewButton.ID = current_order.orderID + "v"; viewButton.CommandArgument = current_order.orderID.ToString(); viewButton.ImageUrl = "/images/left-list.gif"; viewButton.Command += new CommandEventHandler(func_View); retControl = viewButton; } else if (Security.IsAuthorized(getUserID(), PwasObject.Order, PwasAction.Update, PwasScope.Self) && OrderUtilities.isMyOrder(current_order.orderID, getUserID())) { ImageButton viewButton = new ImageButton(); viewButton.ID = current_order.orderID + "v"; viewButton.CommandArgument = current_order.orderID.ToString(); viewButton.ImageUrl = "/images/left-list.gif"; viewButton.Command += new CommandEventHandler(func_View); retControl = viewButton; } else { Image image = new Image(); image.ImageUrl = "/images/left-list_gray.gif"; retControl = image; } return(retControl); }
protected void Page_Load(object sender, EventArgs e) { if (Session[Constants.PWAS_SESSION_ID] == null) { Response.Redirect("index.aspx"); } this.tblViewOrder.Visible = true; this.formEditOrder.Visible = false; panelAlert.Visible = false; panelAlertEmployee.Visible = false; IOrderRepository orderRepository = RepositoryFactory.Get <IOrderRepository>(); int userID = getUserID(); IQueryable <Order> orders_User = OrderUtilities.getOrdersByUser(userID, Response);// getOrdersByUser(userID); foreach (Order current_order in orders_User) { TableRow row = new TableRow(); TableCell cellOrderID = new TableCell(); TableCell cellJobName = new TableCell(); TableCell cellPrice = new TableCell(); TableCell cellStatus = new TableCell(); TableCell cellDate = new TableCell(); TableCell cellEdit = new TableCell(); TableCell cellView = new TableCell(); cellOrderID.Controls.Add(new LiteralControl(current_order.orderID.ToString())); cellJobName.Controls.Add(new LiteralControl(current_order.job_name.ToString())); cellPrice.Controls.Add(new LiteralControl(getOrderPrice(current_order.orderID))); cellStatus.Controls.Add(getStatusControl(current_order)); cellDate.Controls.Add(new LiteralControl(OrderUtilities.getCurrentOrderStatusDate(current_order.orderID))); cellEdit.Controls.Add(getEditButton(current_order)); cellView.Controls.Add(getViewButton(current_order)); //pixels //cellEdit.Width = Unit.Pixel(50); //cellView.Width = Unit.Pixel(50); cellOrderID.Width = Unit.Pixel(100); cellJobName.Width = Unit.Pixel(200); cellPrice.Width = Unit.Pixel(150); cellStatus.Width = Unit.Pixel(150); cellDate.Width = Unit.Pixel(200); //Center cellEdit.HorizontalAlign = HorizontalAlign.Center; cellDate.HorizontalAlign = HorizontalAlign.Center; cellStatus.HorizontalAlign = HorizontalAlign.Center; cellOrderID.HorizontalAlign = HorizontalAlign.Center; cellPrice.HorizontalAlign = HorizontalAlign.Center; cellView.HorizontalAlign = HorizontalAlign.Center; row.Cells.Add(cellEdit); row.Cells.Add(cellView); row.Cells.Add(cellOrderID); row.Cells.Add(cellJobName); row.Cells.Add(cellPrice); row.Cells.Add(cellStatus); row.Cells.Add(cellDate); row.CssClass = "orderRow"; this.orderHistoryTable.Rows.Add(row); } }