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 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 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 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 }); } }
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")); }