public ActionResult Edit([Bind(Include = "orderNr,status,actualQuantity")] ProcessOrder order) { IProcessOrderService ps = new ProcessOrderService(Settings.Default.db); ps.Update(order); return(RedirectToAction("Index")); }
public IActionResult Post([FromBody] Order order) { ProcessOrderService.ProcessOrder(order); StaticStorage.MarketOrders.Add(order); return(Ok(order)); }
private ProcessOrder GetProcessOrderById(string id) { IProcessOrderService ps = new ProcessOrderService(Settings.Default.db); ProcessOrder order = ps.FindById(id); return(order); }
public ActionResult Cancel() { var v = Request.Form.Get("cancelOrderIds"); IProcessOrderService ps = new ProcessOrderService(Settings.Default.db); ps.CancelOrdersByIds(v.Split(',').ToList(), false); return(RedirectToAction("Index")); }
public ActionResult Delete(string id, FormCollection collection) { //try //{ IProcessOrderService ps = new ProcessOrderService(Settings.Default.db); ps.DeleteById(id); return(RedirectToAction("Index")); //} //catch //{ // return View(); //} }
public ActionResult Finish() { var v = Request.Form.Get("finishOrderIds"); IProcessOrderService ps = new ProcessOrderService(Settings.Default.db); ps.FinishOrdersByIds(v.Split(',').ToList(), DateTime.Now, Settings.Default.stockContainer, Settings.Default.stockWh, Settings.Default.stockPosition, Settings.Default.stockSource, Settings.Default.stockSourceType, StockMoveType.ManualEntry, true); return(RedirectToAction("Index")); }
public ActionResult Index(int?page) { int pageIndex = PagingHelper.GetPageIndex(page); ProcessOrderSearchModel q = new ProcessOrderSearchModel(); IProcessOrderService ps = new ProcessOrderService(Settings.Default.db); IPagedList <ProcessOrder> processOrders = ps.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize); ViewBag.Query = q; SetProcessOrderStatusList(null); SetPartTypeList(null); SetProcessOrderMrpRoundList(null); //ProcessOrderInfoModel info = ps.GetProcessOrderInfo(q); //ViewBag.Info = info; return(View(processOrders)); }
public ActionResult Search([Bind(Include = "OrderNr,SourceDoc,DerivedFrom,ProceeDateFrom,ProceeDateTo,PartNr,ActualQuantityFrom,ActualQuantityTo,CompleteRateFrom,CompleteRateTo,Status,MrpRound,KanbanNr,PartType,CreateAtFrom,CreateAtTo")] ProcessOrderSearchModel q) { int pageIndex = 0; int.TryParse(Request.QueryString.Get("page"), out pageIndex); pageIndex = PagingHelper.GetPageIndex(pageIndex); IProcessOrderService ps = new ProcessOrderService(Settings.Default.db); IPagedList <ProcessOrder> processOrders = ps.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize); ViewBag.Query = q; SetProcessOrderStatusList(q.Status); SetPartTypeList(q.PartType); SetProcessOrderMrpRoundList(q.MrpRound); //ProcessOrderInfoModel info = ps.GetProcessOrderInfo(q); //ViewBag.Info = info; return(View("Index", processOrders)); }
public ActionResult ImportForceRecord(HttpPostedFileBase forceFile) { int csvStartFromLine = 16; int excelStartFromLine = 9; //try //{ if (forceFile == null) { throw new Exception("No file is uploaded to system"); } var appData = Server.MapPath("~/TmpFile/"); var filename = Path.Combine(appData, DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + Path.GetFileName(forceFile.FileName)); forceFile.SaveAs(filename); string ex = Path.GetExtension(filename); List <CuttingOrderImportModel> records = new List <CuttingOrderImportModel>(); if (ex.Equals(".csv")) { CsvConfiguration configuration = new CsvConfiguration(); configuration.Delimiter = Settings.Default.csvDelimiter; configuration.HasHeaderRecord = true; configuration.SkipEmptyRecords = true; configuration.RegisterClassMap <ProcessOrderCsvModelMap>(); configuration.TrimHeaders = true; configuration.TrimFields = true; using (TextReader treader = System.IO.File.OpenText(filename)) { for (int i = 0; true; i++) { string s = treader.ReadLine(); if (i >= csvStartFromLine) { if (string.IsNullOrWhiteSpace(s)) { break; } string[] fields = s.Split(char.Parse(Settings.Default.csvDelimiter)); records.Add(new CuttingOrderImportModel() { type = CuttingOrderImportModelType.White, Date = fields[0], Time = fields[1], CuttingOrder = fields[2], CuttingPosition = fields[3], SingleResource = fields[4], ResourceGroup = fields[5], StaffNumber = fields[6], WireNumber = fields[7], PartNumber = fields[8], KanbanNumber = fields[9], CutQtyDisplay = fields[10] }); } } } } else if (Path.GetExtension(filename).Equals(".xlsx")) { FileInfo file = new FileInfo(filename); using (ExcelPackage ep = new ExcelPackage(file)) { ExcelWorksheet ws = ep.Workbook.Worksheets.First(); //string s = ws.Cells[1, 1].Value.ToString(); //s = ws.Cells[1, 2].ToString(); //int i = ws.Dimension.End.Row; // int ii = ws.Dimension.End.Row; for (int i = excelStartFromLine; i <= ws.Dimension.End.Row; i++) { string f = ws.Cells[i, 17].Value.ToString(); int feedback = int.Parse(ws.Cells[i, 17].Value.ToString()); if (feedback > 0) { records.Add(new CuttingOrderImportModel() { type = CuttingOrderImportModelType.Blue, Date = ws.Cells[i, 1].Value.ToString(), Time = ws.Cells[i, 2].Value.ToString(), // CuttingOrder = fields[2], // CuttingPosition = fields[3], // SingleResource = fields[4], ResourceGroup = ws.Cells[i, 10].Value.ToString(), // StaffNumber = fields[6], // WireNumber = fields[7], PartNumber = ws.Cells[i, 11].Value.ToString(), KanbanNumber = ws.Cells[i, 13].Value.ToString(), CutQtyDisplay = ws.Cells[i, 17].Value.ToString() }); } } } } bool success = true; List <BatchFinishOrderRecord> vr = new List <BatchFinishOrderRecord>(); foreach (CuttingOrderImportModel r in records) { vr.Add(new BatchFinishOrderRecord() { Id = r.Id, FixOrderNr = r.KanbanNumber, PartNr = r.PartNumber, Amount = r.CutQty, ProdTime = r.CutDateTime }); } if (vr.Count > 0) { IProcessOrderService ps = new ProcessOrderService(Settings.Default.db); Hashtable results = ps.ValidateFinishOrder(vr); success = Settings.Default.ignoreImportKBOrderError ? true : !results.ContainsKey("WARN"); ViewBag.Success = success; if (success) { ps.BatchFinishOrder(results["SUCCESS"] as List <BatchFinishOrderRecord>, true, false); ViewBag.Msg = "Finish Success!"; return(View()); } else { ViewBag.Msg = "Validate Warning!"; return(View(results["WARN"] as List <BatchFinishOrderRecord>)); } } else { ViewBag.Msg = "No Record"; return(View()); } //} //catch (Exception ex) { // throw ex; // ViewBag.Msg = ex.Message; // return View(); //} }
public void ExportKB([Bind(Include = "OrderNr,SourceDoc,DerivedFrom,ProceeDateFrom,ProceeDateTo,PartNr,ActualQuantityFrom,ActualQuantityTo,CompleteRateFrom,CompleteRateTo,Status,MrpRound,PartType,CreateAt")] ProcessOrderSearchModel q) { var isNew = Request.QueryString["isNew"]; IProcessOrderService ps = new ProcessOrderService(Settings.Default.db); if (!q.ActualQuantityFrom.HasValue) { q.ActualQuantityFrom = 0.0000009; } List <ProcessOrder> processOrders = ps.Search(q).ToList(); ViewBag.Query = q; MemoryStream ms = new MemoryStream(); using (StreamWriter sw = new StreamWriter(ms, Encoding.UTF8)) { List <string> head = new List <string> { " No.", "Product", "PartNr", "Kanban", "PartType(KB Type)", "Position", "ActualQuantity", "BundleQuantity", "BatchQuantity", "KanBanPosition", "RouteNr", "ChangeQty", "CreateAt", "CurrentStock" }; sw.WriteLine(string.Join(Settings.Default.csvDelimiter, head)); for (var i = 0; i < processOrders.Count; i++) { List <string> ii = new List <string>(); ii.Add((i + 1).ToString()); double sourceQuantity = processOrders[i].sourceQuantity; double actualQuantity = processOrders[i].actualQuantity; double kanbanBundleQty = processOrders[i].Part.kanbanBundleQty; double kanbanBatchQty = processOrders[i].Part.kanbanBatchQty; #region V2 if ((!string.IsNullOrEmpty(isNew))) { //if (processOrders[i].currentStock >= 0) //{ ProcessOrderSearchModel qq = new ProcessOrderSearchModel() { PartNrAct = processOrders[i].partNr, Status = processOrders[i].status, ProceeDateTo = processOrders[i].proceeDate }; List <ProcessOrder> orders = ps.Search(qq).ToList(); double qty = processOrders[i].currentStock >= 0 ? sourceQuantity : processOrders[i].requirementQuantity.Value; if (orders.Count > 0) { qty = 0; foreach (ProcessOrder o in orders) { qty += (processOrders[i].currentStock >= 0 ? o.sourceQuantity : o.requirementQuantity.Value); } } sourceQuantity = qty; if (kanbanBundleQty > 0) { if (sourceQuantity % kanbanBundleQty == 0) { // do nothing } else { actualQuantity = kanbanBundleQty * (((int)(sourceQuantity / kanbanBundleQty)) + 1); } } //} } #endregion #region V1 //if ((!string.IsNullOrEmpty(isNew)) && processOrders[i].currentStock > 0) //{ // ProcessOrderSearchModel qq = new ProcessOrderSearchModel() // { // PartNrAct = processOrders[i].partNr, // Status = processOrders[i].status, // ProceeDateTo = processOrders[i].proceeDate // }; // List<ProcessOrder> orders = ps.Search(qq).ToList(); // double qty = sourceQuantity; // if (orders.Count > 0) // { // qty = 0; // foreach (ProcessOrder o in orders) // { // qty += o.sourceQuantity; // } // } // sourceQuantity = qty; // if (kanbanBundleQty > 0) // { // if (sourceQuantity % kanbanBundleQty == 0) // { // // do nothing // } // else // { // actualQuantity = kanbanBundleQty * (((int)(sourceQuantity / kanbanBundleQty)) + 1); // } // } //} #endregion ii.Add(processOrders[i].Part.productNr); ii.Add(processOrders[i].partNr); ii.Add(processOrders[i].Part.kanbanNrs); ii.Add(processOrders[i].Part.partTypeDisplay); ii.Add(processOrders[i].Part.kanbanPosition); ii.Add(actualQuantity.ToString()); ii.Add(kanbanBundleQty.ToString()); ii.Add(processOrders[i].Part.kanbanBatchQty.ToString()); ii.Add(processOrders[i].Part.kanbanPosition.ToString()); ii.Add(processOrders[i].Part.routeNr.ToString()); ii.Add(actualQuantity > kanbanBatchQty ? "Y" : "N"); ii.Add(processOrders[i].createAt.ToString()); ii.Add(processOrders[i].currentStock.ToString()); sw.WriteLine(string.Join(Settings.Default.csvDelimiter, ii.ToArray())); } //sw.WriteLine(max); } var filename = "Kanban" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv"; var contenttype = "text/csv"; Response.Clear(); Response.ContentEncoding = Encoding.UTF8; Response.ContentType = contenttype; Response.AddHeader("content-disposition", "attachment;filename=" + filename); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(ms.ToArray()); Response.End(); }
public ActionResult ImportRecord(HttpPostedFileBase stockFile) { int excelStartFromLine = 2; //try //{ if (stockFile == null) { throw new Exception("No file is uploaded to system"); } var appData = Server.MapPath("~/TmpFile/"); var filename = Path.Combine(appData, DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + Path.GetFileName(stockFile.FileName)); stockFile.SaveAs(filename); string ex = Path.GetExtension(filename); List <BatchFinishOrderRecord> vr = new List <BatchFinishOrderRecord>(); IBatchOrderTemplateService bs = new BatchOrderTemplateService(Settings.Default.db); if (Path.GetExtension(filename).Equals(".xlsx")) { FileInfo file = new FileInfo(filename); using (ExcelPackage ep = new ExcelPackage(file)) { ExcelWorksheet ws = ep.Workbook.Worksheets.First(); for (int i = excelStartFromLine; i <= ws.Dimension.End.Row; i++) { string partNr = ws.Cells[i, 1].Value == null ? string.Empty : ws.Cells[i, 1].Value.ToString(); string kanbanNr = ws.Cells[i, 2].Value == null ? string.Empty : ws.Cells[i, 2].Value.ToString(); float qty = 0; float.TryParse(ws.Cells[i, 3].Value.ToString(), out qty); StockMoveType type = (StockMoveType)(int.Parse(ws.Cells[i, 4].Value.ToString())); DateTime dt = DateTime.Now.Date; if (ws.Cells[i, 5].Value != null) { DateTime.TryParse(ws.Cells[i, 5].Value.ToString(), out dt); } if (string.IsNullOrWhiteSpace(partNr) && (!string.IsNullOrWhiteSpace(kanbanNr))) { BatchOrderTemplate kb = bs.FindByNr(kanbanNr); if (kb != null) { partNr = kb.partNr; } } if (!string.IsNullOrWhiteSpace(partNr)) { vr.Add(new BatchFinishOrderRecord() { Id = string.Format("{0}_{1}_{2}_{3}_{4}", partNr, kanbanNr, qty, type, dt), MoveType = type, PartNr = partNr, Amount = qty, ProdTime = dt }); } } } } bool success = true; if (vr.Count > 0) { IProcessOrderService ps = new ProcessOrderService(Settings.Default.db); ViewBag.Success = true; if (success) { ps.BatchFinishOrder(vr, true, false); ViewBag.Msg = "Import Stock Success!"; return(View()); } else { ViewBag.Msg = "Validate Warning!"; return(View()); } } else { ViewBag.Msg = "No Record"; return(View()); } }