public ActionResult UpdateDatabase() { // 修正内容を含む、注文情報を Session から取得 DataTable orderTable = (DataTable)Session["Orders"]; DataTable orderDetailTable = (DataTable)Session["OrderDetails"]; // Model(業務ロジッククラス) に渡すパラメータを定義 OrderParameterValue param = new OrderParameterValue( this.RouteData.Values["controller"].ToString(), this.RouteData.Values["action"].ToString(), "UpdateOrder", "SQL", //string.Empty, new MyUserInfo("user01", this.UserInfo.IPAddress)); param.Orders = orderTable; param.OrderDetails = orderDetailTable; // Model(業務ロジッククラス) のメソッドを実行 OrdersLogic logic = new OrdersLogic(); OrderReturnValue retValue = (OrderReturnValue)logic.DoBusinessLogic(param); // Model の修正内容を確定させる orderTable.AcceptChanges(); orderDetailTable.AcceptChanges(); // ビューを表示する retValue.Orders = orderTable; retValue.OrderDetails = orderDetailTable; return(View("Order", retValue)); }
public void AnotherTryForFindingAgents() //ניסיון למצוא שליחים לכל ההזמנות שאין להם שליחים { OrdersLogic ol = new OrdersLogic(); ol.AnotherTryForFindingAgents(); }
protected override void OnClosed() { base.OnClosed(); UsersLogic.Dispose(); BooksLogic.Dispose(); OrdersLogic.Dispose(); }
private void Save() { using (StartOperation()) { var orderedBookDescriptions = Order.OrderedBooks .Select(ob => new OrderedBookDescription { BookId = ob.BookId, BookTitle = ob.Book.Title, Amount = ob.Amount }) .ToList(); var validationMessage = OrdersLogic.ValidateOrder(_employee.BranchId, orderedBookDescriptions); if (!validationMessage.IsNullOrEmpty()) { ErrorMessage = validationMessage; return; } Order.Date = DateTime.Now; Order.Customer = Customer; OrdersLogic.SaveOrder(_employee.BranchId, Customer.Id, _employee.Id, orderedBookDescriptions); Close(true); } }
// GET: Order public ActionResult Index() { // Model(業務ロジッククラス) に渡すパラメータを定義 OrderParameterValue param = new OrderParameterValue( this.RouteData.Values["controller"].ToString(), this.RouteData.Values["action"].ToString(), "GetOrders", "SQL", //string.Empty, new MyUserInfo("user01", this.UserInfo.IPAddress)); // Model(業務ロジッククラス) のメソッドを実行 OrdersLogic lb = new OrdersLogic(); OrderReturnValue retValue = (OrderReturnValue)lb.DoBusinessLogic(param); if (retValue.ErrorFlag == true) { // エラーが発生した場合は、エラー内容を Model クラスに格納 string Message = "ErrorMessageID:" + retValue.ErrorMessageID + ";"; Message += "ErrorMessage:" + retValue.ErrorMessage + ";"; Message += "ErrorInfo:" + retValue.ErrorInfo; retValue.Message = Message; } // ビューに戻り値クラスのオブジェクトを渡し、ビューを表示する return(View(retValue)); }
public ActionResult Order(string OrderId) { // Model(業務ロジッククラス) に渡すパラメータを定義 OrderParameterValue param = new OrderParameterValue( this.RouteData.Values["controller"].ToString(), this.RouteData.Values["action"].ToString(), "GetOrderById", "SQL", //string.Empty, new MyUserInfo("user01", this.UserInfo.IPAddress)); param.OrderId = OrderId; // Model(業務ロジッククラス) のメソッドを実行 OrdersLogic logic = new OrdersLogic(); OrderReturnValue retValue = (OrderReturnValue)logic.DoBusinessLogic(param); if (retValue.ErrorFlag == true) { // エラーが発生した場合は、エラー内容を Model クラスに格納 string Message = "ErrorMessageID:" + retValue.ErrorMessageID + ";"; Message += "ErrorMessage:" + retValue.ErrorMessage + ";"; Message += "ErrorInfo:" + retValue.ErrorInfo; retValue.Message = Message; } else { // 正常に終了した場合は、DB から取得した値を Session に格納 Session["Orders"] = retValue.Orders; Session["OrderDetails"] = retValue.OrderDetails; } return(View(retValue)); }
public IHttpActionResult SendReport(string token, int userId, int orderId, string email) { if (!ApplicationHelper.IsTokenValid(token, userId)) { return(Content(HttpStatusCode.BadRequest, "BadRequest")); } var order = OrdersLogic.GetOrder(orderId); if (order == null) { return(Content(HttpStatusCode.NotFound, "NotFound")); } var result = OrdersLogic.SendReport(order, email); if (!result.Success) { ApplicationHelper.Log(result.Message); } return(result.Success ? Content(HttpStatusCode.OK, "OK") : Content(HttpStatusCode.InternalServerError, result.Message)); }
public IHttpActionResult UpdateOrder(string token, int userId, Order order) { if (!ModelState.IsValid || !ApplicationHelper.IsTokenValid(token, userId)) { return(Content(HttpStatusCode.BadRequest, "BadRequest")); } var orderDb = OrdersLogic.GetOrder(order.orderId); if (orderDb == null) { return(Content(HttpStatusCode.NotFound, "NotFound")); } var result = OrdersLogic.UpdateOrder(order); if (!result.Success) { ApplicationHelper.Log(result.Message); } return(result.Success ? Content(HttpStatusCode.OK, "OK") : Content(HttpStatusCode.InternalServerError, result.Message)); }
public string LoadProducts(string OrderID) { try { if (Context.User.IsInRole("Administrator")) { string HTML = ""; Guid myOrderID = Guid.Parse(OrderID.Trim()); List <OrderProduct> myProductItems = new OrdersLogic().RetrieveItemsByOrderID(myOrderID).ToList(); HTML += "<table>"; int Counter = 0; foreach (OrderProduct myProductItem in myProductItems) { HTML += "<tr class=\"GridViewTuple\">"; HTML += "<td>"; HTML += new ProductsLogic().RetrieveProductByID(myProductItem.ProductFK.ToString()).Name; HTML += "</td>"; HTML += "<td>"; HTML += "<div style=\"padding-top: 4px; float: left;\">x </div><input class=\"CatalogTextBox\" id=\"" + myProductItem.ProductFK + "\" Use=\"Quantity\" type=\"text\" value=\"" + myProductItem.Quantity.ToString() + "\">"; HTML += "</td>"; HTML += "<td>"; HTML += "<input type=\"button\" ProductID=\"" + myProductItem.ProductFK + "\" Use=\"Update\" value=\"Update\">"; HTML += "</td>"; HTML += "<td>"; HTML += "<input type=\"button\" ProductID=\"" + myProductItem.ProductFK + "\" Use=\"Remove\" value=\"Remove\">"; HTML += "</td>"; HTML += "<td>"; HTML += "<div Use=\"ErrorDiv\" ProductID=\"" + myProductItem.ProductFK + "\" class=\"MiniFontBlue\">Not Enough Stock</div>"; HTML += "</td>"; HTML += "</tr>"; Counter++; } HTML += "</table>"; return(HTML); } else { return(""); } } catch (Exception Exception) { throw Exception; } }
public ActionResult OrderAdd(OrderParameter param) { try { return(Json(OrdersLogic.getInstance().Add(param), JsonRequestBehavior.AllowGet)); } catch (Exception e) { Logging.Log.getInstance().CreateLogError(e); return(Json(e.Message, JsonRequestBehavior.AllowGet)); } }
public ActionResult Activity() { var page = new PagedList <sp_OrderMonitoring_Result>(); try { var model = OrdersLogic.getInstance().GetAllActivity().ToList(); page.Content = model; } catch (Exception e) { Logging.Log.getInstance().CreateLogError(e); } return(View(page)); }
public ActionResult History() { var page = new PagedList <sp_RiwayatPengambilanBBM_Result>(); try { var model = OrdersLogic.getInstance().GetAllHistory().ToList(); page.Content = model; } catch (Exception e) { Logging.Log.getInstance().CreateLogError(e); } return(View(page)); }
public IHttpActionResult GetOrder(string token, int userId, int id) { if (!ApplicationHelper.IsTokenValid(token, userId)) { return(Content(HttpStatusCode.BadRequest, "BadRequest")); } var order = OrdersLogic.GetOrder(id); if (order == null) { return(Content(HttpStatusCode.NotFound, "NotFound")); } return(Content(HttpStatusCode.OK, order)); }
private void Save() { using (StartOperation()) { var validationMessage = OrdersLogic.ValidateOrder(Order, _employee.BranchId); if (!validationMessage.IsNullOrEmpty()) { ErrorMessage = validationMessage; return; } Order.Date = DateTime.Now; Order.Customer = Customer; OrdersLogic.SaveOrder(Order, _employee.BranchId); Close(true); } }
//get all clients orders public IEnumerable GetAllOrders(string option) { OrdersLogic orders = new OrdersLogic(); switch (option) { case "All": return(orders.GetAllOrders()); case "Open": return(orders.GetAllOpenOrders()); case "Closed": return(orders.GetAllClosedOrders()); default: return(orders.GetAllOrders()); } }
public List <OrdersLogic> DisplayOrdersDB() { //string connectionString = SecretConfiguration.configurationString; string connectionString = ""; DbContextOptions <GameStoreContext> options = new DbContextOptionsBuilder <GameStoreContext>() .UseSqlServer(connectionString) .Options; using var context = new GameStoreContext(options); using var context2 = new GameStoreContext(options); using var context3 = new GameStoreContext(options); using var context4 = new GameStoreContext(options); using var context5 = new GameStoreContext(options); List <OrdersLogic> orders = new List <OrdersLogic>(); foreach (Orders order in context.Orders) { OrdersLogic tempOrder = new OrdersLogic(); tempOrder.OrderId = order.OrderId; tempOrder.OrderDate = order.OrderDate; tempOrder.Quantity = (int)order.Quantity; var foundName = context2.Customers.FirstOrDefault(p => p.CustomerId == order.CustomerId); tempOrder.CustomerName = foundName.FirstName + " " + foundName.LastName; var foundProduct = context3.OrderedProducts.FirstOrDefault(p => p.CustomerId == foundName.CustomerId && p.OrderId == order.OrderId); var foundProductName = context4.Products.FirstOrDefault(p => p.ProductId == foundProduct.ProductId); var foundLocName = context5.Locations.FirstOrDefault(p => p.LocationId == foundProduct.LocationId); tempOrder.LocationName = foundLocName.City; tempOrder.ProductName = foundProductName.ProductName; orders.Add(tempOrder); } return(orders); }
public ActionResult Orders() { //Another check if user is logged in and is an admin. var cookievalue = Request.Cookies["user"].Value.ToString(); if (cookievalue == "*****@*****.**") { var orders = OrdersLogic.OrderLogic(); //New model with data from OrdersLogic var viewmodel = new OrdersViewModel { user = orders.user.ToList(), book = orders.book.ToList() }; return(View(viewmodel)); } else { return(RedirectToAction("Index")); } }
public ResponseOrders Order(Orders order) { Orders orderDetails = OrdersLogic.getInstance().Add(order); try { return(new ResponseOrders { status = "success", message = "user successfully inserted", Data = orderDetails }); } catch (Exception e) { Logging.Log.getInstance().CreateLogError(e, JsonConvert.SerializeObject(order)); return(new ResponseOrders { status = "failed", message = e.Message }); } }
/// <summary> /// Occurs when the User Orders Grid View Selected Index is Changed /// Level: External /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvUserOrders_SelectedIndexChanged(object sender, EventArgs e) { try { txtUserID.Visible = true; txtUserID.Text = gvUserOrders.SelectedValue.ToString(); Order myOrder = new OrdersLogic().RetrieveOrderByID(Guid.Parse(gvUserOrders.SelectedValue.ToString())); txtSupplierID.Text = ""; ddlOrderStatus.Visible = true; ddlOrderStatus.SelectedValue = myOrder.OrderStatus.Id.ToString(); btnUpdate.Visible = true; lblOrder.Visible = true; btnPrintContents.Visible = true; btnEditContents.Visible = true; } catch (Exception Exception) { throw Exception; } }
protected void btnShowTable_Click(object sender, EventArgs e) { switch (lstShowTable.SelectedValue) { case "Orders": OrdersLogic orders = new OrdersLogic(); gvwShowTable.DataSource = orders.GetOrders(); break; case "Shows": gvwShowTable.DataSource = shows.GetShows(); break; case "Videos": gvwShowTable.DataSource = videos.GetVideos(); break; case "Users": gvwShowTable.DataSource = users.GetUsers(); break; } gvwShowTable.DataBind(); }
public ActionResult UpdateDatabase() { // 修正内容を含む、注文情報を Session から取得 List <OrderViweModel> ovms = (List <OrderViweModel>)Session["Orders"]; List <Order_DetailViweModel> odvms = (List <Order_DetailViweModel>)Session["OrderDetails"]; // Model(業務ロジッククラス) に渡すパラメータを定義 OrderParameterValue param = new OrderParameterValue( this.RouteData.Values["controller"].ToString(), this.RouteData.Values["action"].ToString(), "UpdateOrder", "SQL", //string.Empty, new MyUserInfo("user01", this.UserInfo.IPAddress)); param.Orders = ovms; param.OrderDetails = odvms; // Model(業務ロジッククラス) のメソッドを実行 OrdersLogic logic = new OrdersLogic(); OrderReturnValue retValue = (OrderReturnValue)logic.DoBusinessLogic(param); // Model の修正内容を確定させる foreach (OrderViweModel ovm in ovms) { ovm.Modified = false; } foreach (Order_DetailViweModel odvm in odvms) { odvm.Modified = false; } // ビューを表示する retValue.Orders = ovms; retValue.OrderDetails = odvms; return(View("Order", retValue)); }
public bool UpdateItem(string OrderID, string ProductID, string OrderType, string Quantity) { try { if (Context.User.IsInRole("Administrator")) { Guid myOrderID = Guid.Parse(OrderID); Guid myProductID = Guid.Parse(ProductID); int myQuantity = Convert.ToInt32(Quantity); bool UpdateSuccessful = false; if (OrderType.Trim() == "User") { UpdateSuccessful = new OrdersLogic().UpdateUserOrderItem(myOrderID, myProductID, myQuantity); return(UpdateSuccessful); } else if (OrderType.Trim() == "Supplier") { UpdateSuccessful = new OrdersLogic().UpdateSupplierOrderItem(myOrderID, myProductID, myQuantity); return(UpdateSuccessful); } return(UpdateSuccessful); } else { return(false); } } catch (Exception Exception) { throw Exception; } }
public bool RemoveItem(string OrderID, string ProductID, string OrderType) { try { if (Context.User.IsInRole("Administrator")) { Guid myOrderID = Guid.Parse(OrderID); Guid myProductID = Guid.Parse(ProductID); bool UpdateSuccessful = false; if (OrderType.Trim() == "User") { new OrdersLogic().RemoveUserOrderItem(myOrderID, myProductID); return(true); } else if (OrderType.Trim() == "Supplier") { UpdateSuccessful = new OrdersLogic().RemoveSupplierOrderItem(myOrderID, myProductID); return(UpdateSuccessful); } return(UpdateSuccessful); } else { return(false); } } catch (Exception Exception) { throw Exception; } }
public void viewOrdersMenu() { int input = 0; Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" +================================================================+"); Console.WriteLine(" | |"); Console.WriteLine(" | ORDERS MENU |"); Console.WriteLine(" | |"); Console.WriteLine(" +================================================================+"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | [1] VIEW ORDERS HISTORY |"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | [2] ADD AN ORDER |"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | [3] |"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | [4] DELETE AN ORDER |"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | [5] RETURN TO MAIN MENU |"); Console.WriteLine(" +----------------------------------------------------------------+"); input = Int32.Parse(Console.ReadLine()); var order = new OrdersLogic(); var products = new ProductsLogic(); switch (input) { case 1: Console.Clear(); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | ORDER CATALOG |"); Console.WriteLine(" +----------------------------------------------------------------+"); order.GetOrders(); break; case 2: Console.Clear(); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | CREATE AN ORDER |"); Console.WriteLine(" +----------------------------------------------------------------+"); order.Add(); break; case 3: break; case 4: Console.Clear(); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | DELETE A ORDER FROM INVENTORY |"); Console.WriteLine(" +----------------------------------------------------------------+"); order.Delete(); break; case 5: Console.Clear(); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | CREATE AN ORDER |"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" Choose an item to add to cart"); //products.GetProducts(); //order.GetCart(); break; default: Console.Clear(); var mainmenu = new MainMenu(); mainmenu.viewMainMenu(); break; } }
//get all the login user orders public IEnumerable GetAllMyOrders(int userID) { OrdersLogic orders = new OrdersLogic(); return(orders.GetAllMyOrders(userID)); }
protected void Page_Load(object sender, EventArgs e) { try { if (Context.User.Identity.IsAuthenticated) { string myOrderID = Request.QueryString[0].ToString(); Guid myOrderGuid; if (Guid.TryParse(myOrderID, out myOrderGuid)) { Order myOrder = new OrdersLogic().RetrieveOrderByID(myOrderGuid); IQueryable <OrderProduct> myOrderItems = new OrdersLogic().RetrieveItemsByOrderID(myOrderGuid); bool HasAccess = false; if (Context.User.IsInRole("Administrator")) { HasAccess = true; } else { if (myOrder.UserFK == new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name).Id) { HasAccess = true; } } //User has access to the order if (HasAccess) { string HTML = "<table style=\"font-family: Arial;\" cellpadding=\"6\">"; HTML += "<tr>"; HTML += "<td>"; HTML += "Order ID: "; HTML += "</td>"; HTML += "<td>"; HTML += myOrder.Id; HTML += "</td>"; HTML += "</tr>"; if (myOrder.SupplierFK == null) { HTML += "<tr>"; HTML += "<td>"; HTML += "Name: "; HTML += "</td>"; HTML += "<td>"; HTML += myOrder.User.Name + " " + myOrder.User.Surname; HTML += "</td>"; HTML += "</tr>"; string[] Address = myOrder.User.StreetAddress.Split('|'); HTML += "<tr>"; HTML += "<td>"; HTML += "Address: "; HTML += "</td>"; HTML += "<td>"; HTML += Address[0]; HTML += "</td>"; HTML += "</tr>"; HTML += "<tr>"; HTML += "<td>"; HTML += "</td>"; HTML += "<td>"; HTML += Address[1]; HTML += "</td>"; HTML += "</tr>"; HTML += "<tr>"; HTML += "<td>"; HTML += "Town: "; HTML += "</td>"; HTML += "<td>"; HTML += myOrder.User.Town.Town1; HTML += "</td>"; HTML += "</tr>"; HTML += "<tr>"; HTML += "<td>"; HTML += "Country: "; HTML += "</td>"; HTML += "<td>"; HTML += myOrder.User.Town.Country.Country1; HTML += "</td>"; HTML += "</tr>"; } else { HTML += "<tr>"; HTML += "<td>"; HTML += "Supplier: "; HTML += "</td>"; HTML += "<td>"; HTML += myOrder.Supplier.Supplier1; HTML += "</td>"; HTML += "</tr>"; } HTML += "<tr>"; HTML += "<td>"; HTML += "Status: "; HTML += "</td>"; HTML += "<td>"; HTML += myOrder.OrderStatus.Status; HTML += "</td>"; HTML += "</tr>"; HTML += "<tr>"; HTML += "<td>"; HTML += "Date Placed: "; HTML += "</td>"; HTML += "<td>"; HTML += myOrder.OrderDate; HTML += "</td>"; HTML += "</tr>"; HTML += "</table>"; HTML += "<br/>"; HTML += "<table style=\"font-family: Arial;\" cellpadding=\"6\">"; HTML += "<tr>"; HTML += "<td>"; HTML += "Product"; HTML += "</td>"; HTML += "<td>"; HTML += "Quantity"; HTML += "</td>"; HTML += "<td>"; HTML += "Price"; HTML += "</td>"; HTML += "<td>"; HTML += "VAT Rate"; HTML += "</td>"; HTML += "<td>"; HTML += "Discount (Incl.)"; HTML += "</td>"; HTML += "</tr>"; double TotalPrice = 0; double TotalVat = 0; foreach (OrderProduct myOrderItem in myOrderItems) { Product myProduct = new ProductsLogic().RetrieveProductByID(myOrderItem.ProductFK.ToString()); User myUser = null; UserTypeProduct myPriceType = null; if (myOrder.UserFK != null) { myUser = new UsersLogic().RetrieveUserByID(Guid.Parse(myOrder.UserFK.ToString())); myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myUser.UserTypeFK, myProduct.Id); } else { UserType myUserType = new UserTypesLogic().RetrieveUserTypeByName("Wholesaler"); myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myUserType.Id, myProduct.Id); } HTML += "<tr>"; HTML += "<td>"; HTML += myProduct.Name; HTML += "</td>"; HTML += "<td>"; HTML += " x " + myOrderItem.Quantity; HTML += "</td>"; HTML += "<td>"; HTML += " at € " + myOrderItem.Price.ToString("F"); HTML += "</td>"; HTML += "<td>"; HTML += myProduct.Vatrate.Vatrate1 + "% VAT"; HTML += "</td>"; TotalPrice += myOrderItem.Price * myOrderItem.Quantity; TotalVat += ((myProduct.Vatrate.Vatrate1 / 100) * (myOrderItem.Price * myOrderItem.Quantity)); HTML += "<td>"; if ((myOrder.OrderDate >= myPriceType.DiscountDateFrom) && (myOrder.OrderDate <= myPriceType.DiscountDateTo)) { HTML += myPriceType.DiscountPercentage + "% Discount"; } HTML += "</td>"; HTML += "</tr>"; } HTML += "<tr>"; HTML += "<td>"; HTML += "</td>"; HTML += "<td>"; HTML += "</td>"; HTML += "<td>"; HTML += "</td>"; HTML += "<td>"; HTML += "Subtotal : "; HTML += "</td>"; HTML += "<td>"; HTML += "€ " + (TotalPrice - TotalVat).ToString("F"); HTML += "</td>"; HTML += "<tr>"; HTML += "<td>"; HTML += "</td>"; HTML += "<td>"; HTML += "</td>"; HTML += "<td>"; HTML += "</td>"; HTML += "<td>"; HTML += "VAT : "; HTML += "</td>"; HTML += "<td>"; HTML += "€ " + TotalVat.ToString("F"); HTML += "</td>"; HTML += "</tr>"; HTML += "<tr>"; HTML += "<td>"; HTML += "</td>"; HTML += "<td>"; HTML += "</td>"; HTML += "<td>"; HTML += "</td>"; HTML += "<td>"; HTML += "Total : "; HTML += "</td>"; HTML += "<td>"; HTML += "€ " + TotalPrice.ToString("F"); HTML += "</td>"; HTML += "</tr>"; HTML += "</table>"; lblOutput.Text = HTML; } else { Response.Redirect("~/default.aspx"); } } } else { Response.Redirect("~/default.aspx"); } } catch (Exception Exception) { throw Exception; } }
public ActionResult ExportToExcel() { try { ExcelPackage Package = new ExcelPackage(); ExcelWorksheet ws = Package.Workbook.Worksheets.Add("Data"); Color colFromHex = System.Drawing.ColorTranslator.FromHtml("#00b0f0"); OfficeOpenXml.Style.ExcelBorderStyle DefaultBorder = OfficeOpenXml.Style.ExcelBorderStyle.Thin; ws.Cells["A1"].LoadFromText("No"); ws.Cells["A1"].Style.Font.SetFromFont(new Font("Cambria", 10)); ws.Cells["A1"].Style.Font.Color.SetColor(Color.White); ws.Cells["A1"].Style.Font.Bold = true; ws.Cells["A1"].Style.Fill.PatternType = ExcelFillStyle.Solid; ws.Cells["A1"].Style.Fill.BackgroundColor.SetColor(colFromHex); ws.Cells["A1"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; ws.Cells["A1"].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; ws.Cells["A1"].Style.Border.Bottom.Style = DefaultBorder; ws.Cells["A1"].Style.Border.Left.Style = DefaultBorder; ws.Cells["A1"].Style.Border.Top.Style = DefaultBorder; ws.Cells["A1"].Style.Border.Right.Style = DefaultBorder; ws.Cells["B1"].LoadFromText("Tanggal Transaksi"); ws.Cells["B1"].Style.Font.SetFromFont(new Font("Cambria", 10)); ws.Cells["B1"].Style.Font.Color.SetColor(Color.White); ws.Cells["B1"].Style.Font.Bold = true; ws.Cells["B1"].Style.Fill.PatternType = ExcelFillStyle.Solid; ws.Cells["B1"].Style.Fill.BackgroundColor.SetColor(colFromHex); ws.Cells["B1"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; ws.Cells["B1"].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; ws.Cells["B1"].Style.Border.Bottom.Style = DefaultBorder; ws.Cells["B1"].Style.Border.Left.Style = DefaultBorder; ws.Cells["B1"].Style.Border.Top.Style = DefaultBorder; ws.Cells["B1"].Style.Border.Right.Style = DefaultBorder; ws.Cells["C1"].LoadFromText("NIP"); ws.Cells["C1"].Style.Font.SetFromFont(new Font("Cambria", 10)); ws.Cells["C1"].Style.Font.Color.SetColor(Color.White); ws.Cells["C1"].Style.Font.Bold = true; ws.Cells["C1"].Style.Fill.PatternType = ExcelFillStyle.Solid; ws.Cells["C1"].Style.Fill.BackgroundColor.SetColor(colFromHex); ws.Cells["C1"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; ws.Cells["C1"].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; ws.Cells["C1"].Style.Border.Bottom.Style = DefaultBorder; ws.Cells["C1"].Style.Border.Left.Style = DefaultBorder; ws.Cells["C1"].Style.Border.Top.Style = DefaultBorder; ws.Cells["C1"].Style.Border.Right.Style = DefaultBorder; ws.Cells["D1"].LoadFromText("Pengguna"); ws.Cells["D1"].Style.Font.SetFromFont(new Font("Cambria", 10)); ws.Cells["D1"].Style.Font.Color.SetColor(Color.White); ws.Cells["D1"].Style.Font.Bold = true; ws.Cells["D1"].Style.Fill.PatternType = ExcelFillStyle.Solid; ws.Cells["D1"].Style.Fill.BackgroundColor.SetColor(colFromHex); ws.Cells["D1"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; ws.Cells["D1"].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; ws.Cells["D1"].Style.Border.Bottom.Style = DefaultBorder; ws.Cells["D1"].Style.Border.Left.Style = DefaultBorder; ws.Cells["D1"].Style.Border.Top.Style = DefaultBorder; ws.Cells["D1"].Style.Border.Right.Style = DefaultBorder; ws.Cells["E1"].LoadFromText("Fuel"); ws.Cells["E1"].Style.Font.SetFromFont(new Font("Cambria", 10)); ws.Cells["E1"].Style.Font.Color.SetColor(Color.White); ws.Cells["E1"].Style.Font.Bold = true; ws.Cells["E1"].Style.Fill.PatternType = ExcelFillStyle.Solid; ws.Cells["E1"].Style.Fill.BackgroundColor.SetColor(colFromHex); ws.Cells["E1"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; ws.Cells["E1"].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; ws.Cells["E1"].Style.Border.Bottom.Style = DefaultBorder; ws.Cells["E1"].Style.Border.Left.Style = DefaultBorder; ws.Cells["E1"].Style.Border.Top.Style = DefaultBorder; ws.Cells["E1"].Style.Border.Right.Style = DefaultBorder; ws.Cells["F1"].LoadFromText("Qty"); ws.Cells["F1"].Style.Font.SetFromFont(new Font("Cambria", 10)); ws.Cells["F1"].Style.Font.Color.SetColor(Color.White); ws.Cells["F1"].Style.Font.Bold = true; ws.Cells["F1"].Style.Fill.PatternType = ExcelFillStyle.Solid; ws.Cells["F1"].Style.Fill.BackgroundColor.SetColor(colFromHex); ws.Cells["F1"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; ws.Cells["F1"].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; ws.Cells["F1"].Style.Border.Bottom.Style = DefaultBorder; ws.Cells["F1"].Style.Border.Left.Style = DefaultBorder; ws.Cells["F1"].Style.Border.Top.Style = DefaultBorder; ws.Cells["F1"].Style.Border.Right.Style = DefaultBorder; int idx = 1; foreach (var item in OrdersLogic.getInstance().GetAllHistoryExport().ToList()) { idx++; ws.Cells["A" + idx.ToString()].LoadFromText(item.No.ToString()); ws.Cells["A" + idx.ToString()].Style.Font.SetFromFont(new Font("Cambria", 10)); ws.Cells["A" + idx.ToString()].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; ws.Cells["A" + idx.ToString()].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; ws.Cells["A" + idx.ToString()].Style.Border.Bottom.Style = DefaultBorder; ws.Cells["A" + idx.ToString()].Style.Border.Left.Style = DefaultBorder; ws.Cells["A" + idx.ToString()].Style.Border.Top.Style = DefaultBorder; ws.Cells["A" + idx.ToString()].Style.Border.Right.Style = DefaultBorder; DateTime?createdDate = item.CreateDate; string strCreatedDate = createdDate.Value.ToString("dd MMM yy HH:mm"); ws.Cells["B" + idx.ToString()].LoadFromText(strCreatedDate); ws.Cells["B" + idx.ToString()].Style.Font.SetFromFont(new Font("Cambria", 10)); ws.Cells["B" + idx.ToString()].Style.Numberformat.Format = "dd MMM yy HH:mm"; ws.Cells["B" + idx.ToString()].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; ws.Cells["B" + idx.ToString()].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; ws.Cells["B" + idx.ToString()].Style.Border.Bottom.Style = DefaultBorder; ws.Cells["B" + idx.ToString()].Style.Border.Left.Style = DefaultBorder; ws.Cells["B" + idx.ToString()].Style.Border.Top.Style = DefaultBorder; ws.Cells["B" + idx.ToString()].Style.Border.Right.Style = DefaultBorder; ws.Cells["C" + idx.ToString()].LoadFromText(item.NIP); ws.Cells["C" + idx.ToString()].Style.Numberformat.Format = "##0"; ws.Cells["C" + idx.ToString()].Style.Font.SetFromFont(new Font("Cambria", 10)); ws.Cells["C" + idx.ToString()].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; ws.Cells["C" + idx.ToString()].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; ws.Cells["C" + idx.ToString()].Style.Border.Bottom.Style = DefaultBorder; ws.Cells["C" + idx.ToString()].Style.Border.Left.Style = DefaultBorder; ws.Cells["C" + idx.ToString()].Style.Border.Top.Style = DefaultBorder; ws.Cells["C" + idx.ToString()].Style.Border.Right.Style = DefaultBorder; ws.Cells["D" + idx.ToString()].LoadFromText(item.Name); ws.Cells["D" + idx.ToString()].Style.Font.SetFromFont(new Font("Cambria", 10)); ws.Cells["D" + idx.ToString()].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; ws.Cells["D" + idx.ToString()].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; ws.Cells["D" + idx.ToString()].Style.Border.Bottom.Style = DefaultBorder; ws.Cells["D" + idx.ToString()].Style.Border.Left.Style = DefaultBorder; ws.Cells["D" + idx.ToString()].Style.Border.Top.Style = DefaultBorder; ws.Cells["D" + idx.ToString()].Style.Border.Right.Style = DefaultBorder; ws.Cells["E" + idx.ToString()].LoadFromText(item.Fuel); ws.Cells["E" + idx.ToString()].Style.Font.SetFromFont(new Font("Cambria", 10)); ws.Cells["E" + idx.ToString()].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; ws.Cells["E" + idx.ToString()].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; ws.Cells["E" + idx.ToString()].Style.Border.Bottom.Style = DefaultBorder; ws.Cells["E" + idx.ToString()].Style.Border.Left.Style = DefaultBorder; ws.Cells["E" + idx.ToString()].Style.Border.Top.Style = DefaultBorder; ws.Cells["E" + idx.ToString()].Style.Border.Right.Style = DefaultBorder; ws.Cells["F" + idx.ToString()].LoadFromText(item.Liter.ToString()); ws.Cells["F" + idx.ToString()].Style.Font.SetFromFont(new Font("Cambria", 10)); ws.Cells["F" + idx.ToString()].Style.Numberformat.Format = "#,#0 Liter"; ws.Cells["F" + idx.ToString()].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; ws.Cells["F" + idx.ToString()].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; ws.Cells["F" + idx.ToString()].Style.Border.Bottom.Style = DefaultBorder; ws.Cells["F" + idx.ToString()].Style.Border.Left.Style = DefaultBorder; ws.Cells["F" + idx.ToString()].Style.Border.Top.Style = DefaultBorder; ws.Cells["F" + idx.ToString()].Style.Border.Right.Style = DefaultBorder; } Response.Clear(); Response.Buffer = true; Response.Charset = ""; Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AddHeader("content-disposition", "attachment;filename=RiwayatPengambilanBBM_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".xlsx"); Response.BinaryWrite(Package.GetAsByteArray()); Response.End(); } catch (Exception e) { Logging.Log.getInstance().CreateLogError(e); } return(View("Index")); }
protected void Page_Load(object sender, EventArgs e) { try { string StartDate = null; string EndDate = null; string Users = null; if ((Request.QueryString["sd"] != null) && (Request.QueryString["ed"] != null)) { StartDate = Request.QueryString["sd"].ToString(); EndDate = Request.QueryString["ed"].ToString(); } else if (Request.QueryString["u"] != null) { Users = Request.QueryString["u"].ToString(); } else { Response.Redirect("~/pagenotfound.aspx"); } string HTML = ""; if (Users == null) { DateTime myStartDate = new DateTime(); DateTime myEndDate = new DateTime(); try { myStartDate = new DateTimeParser().ParseDate(StartDate.Replace('/', '-')); myEndDate = new DateTimeParser().ParseDate(EndDate.Replace('/', '-')); } catch (Exception) { Response.Redirect("~/pagenotfound.aspx"); } if (myStartDate > myEndDate) { DateTime myInitialStartDate = myStartDate; DateTime myInitialEndDate = myEndDate; myStartDate = myInitialEndDate; myEndDate = myInitialStartDate; } IQueryable <TopTenView> myTopTenList = new OrdersLogic().RetrieveTopTen(myStartDate, myEndDate); HTML = "<table style=\"font-family: Arial;\" cellpadding=\"6\">"; HTML += "<tr>"; HTML += "<td>"; HTML += "Start Date:"; HTML += "</td>"; HTML += "<td>"; HTML += myStartDate.ToShortDateString(); HTML += "</td>"; HTML += "</tr>"; HTML += "<tr>"; HTML += "<td>"; HTML += "End Date:"; HTML += "</td>"; HTML += "<td>"; HTML += myEndDate.ToShortDateString(); HTML += "</td>"; HTML += "</tr>"; HTML += "</table>"; HTML += "<br/>"; HTML += "<br/>"; HTML += "<table style=\"font-family: Arial;\" cellpadding=\"6\">"; HTML += "<tr>"; HTML += "<td>"; HTML += "Rank"; HTML += "</td>"; HTML += "<td>"; HTML += "Product Name"; HTML += "</td>"; HTML += "<td>"; HTML += "Product Description"; HTML += "</td>"; HTML += "<td>"; HTML += "Quantity Bought"; HTML += "</td>"; HTML += "<tr>"; int Counter = 0; foreach (TopTenView myTopTenItem in myTopTenList) { Counter++; if (Counter > 10) { break; } HTML += "<tr>"; HTML += "<td>"; HTML += Counter; HTML += "</td>"; HTML += "<td>"; HTML += myTopTenItem.ProductName; HTML += "</td>"; HTML += "<td>"; HTML += myTopTenItem.ProductDescription; HTML += "</td>"; HTML += "<td>"; HTML += myTopTenItem.QuantitySold; HTML += "</td>"; HTML += "</tr>"; } HTML += "</table>"; } else { IQueryable <TopTenClients> myTopTenList = new OrdersLogic().RetrieveTopTenClients(); HTML += "<table style=\"font-family: Arial;\" cellpadding=\"6\">"; HTML += "<tr>"; HTML += "<td>"; HTML += "Rank"; HTML += "</td>"; HTML += "<td>"; HTML += "Client Name"; HTML += "</td>"; HTML += "<td>"; HTML += "Quantity Bought"; HTML += "</td>"; HTML += "<tr>"; int Counter = 0; foreach (TopTenClients myTopTenItem in myTopTenList) { Counter++; if (Counter > 10) { break; } HTML += "<tr>"; HTML += "<td>"; HTML += Counter; HTML += "</td>"; HTML += "<td>"; HTML += myTopTenItem.ClientName; HTML += "</td>"; HTML += "<td>"; HTML += myTopTenItem.ProductCount; HTML += "</td>"; HTML += "</tr>"; } HTML += "</table>"; } lblOutput.Text = HTML; } catch (Exception Exception) { throw Exception; } }