public ActionResult EditDocumentTaskCenter(DocumentTaskCenter c) { var toUpdate = taskCenterRepository.GetDocumentTaskCenter(c.CodDocumentTaskCenter); toUpdate.DocumentName = c.DocumentName; toUpdate.FieldA = c.FieldA; toUpdate.FieldB = c.FieldB; toUpdate.FieldC = c.FieldC; try { toUpdate.AlarmStartingAt = DateTime.Parse(c.AlarmStartingAtString, new CultureInfo(CultureInfo.CurrentCulture.ToString()), System.Globalization.DateTimeStyles.AssumeLocal); } catch (Exception) { } try { toUpdate.AlarmFinishingAt = DateTime.Parse(c.AlarmFinishingAtString, new CultureInfo(CultureInfo.CurrentCulture.ToString()), System.Globalization.DateTimeStyles.AssumeLocal); } catch (Exception) { } taskCenterRepository.EditDocumentTaskCenter(toUpdate); taskCenterRepository.Save(); UpdateAndReloadPlanning(); return null; }
/// <summary> /// create fisical new order /// </summary> /// <returns></returns> private Order NewOrder(string codDocumentProduct) { var c = new Order(); c.CodDocument = documentRepository.GetNewCode(c); c.OrderNumberSerie = DateTime.Now.Year.ToString(); c.OrderNumber = documentRepository.GetNewOrderNumber(c); var docProd = documentRepository.GetDocumentProductByCodDocumentProduct(codDocumentProduct); c.OrderProduct = docProd; c.CodCustomer = docProd.Document.CodCustomer; c.Customer = docProd.Document.Customer; c.DateDocument = DateTime.Now; var allStates = documentRepository.GetAllStates().Where(x => (x.UseInOrder ?? false)).OrderBy(x => x.StateNumber); foreach (var s in allStates) { c.DocumentStates.Add(new DocumentState { CodDocument = c.CodDocument, StateNumber = s.StateNumber, CodState = s.CodState, // StateName = s.StateName, //derivated!!! ResetLinkedStates = s.ResetLinkedStates, Selected = false }); } documentRepository.Add(c); documentRepository.Save(); //se ci sono dei TaskCenter inizio a buttare i taskcenter nel primo taskcenter (IndexOf==0) var taskCenter = taskCenterRepository.GetAll().Where(y => y.IndexOf == 0).FirstOrDefault(); var prod = productRepository.GetSingle(docProd.CodProduct); if (taskCenter != null) { DocumentTaskCenter dtc = new DocumentTaskCenter(); dtc.CodTaskCenter = taskCenter.CodTaskCenter; dtc.CodDocument = c.CodDocument; if (docProd.Product.ProductRefName == null) { dtc.DocumentName = docProd.ProductName; } else { dtc.DocumentName = docProd.Product.ProductRefName; } try { dtc.FieldA = prod.GetColorOfPrinting(); } catch (Exception) { } taskCenterRepository.AddNewDocumentTaskCenter(dtc); taskCenterRepository.Save(); } foreach (var item in prod.ProductParts) { foreach (var p in item.ProductPartPrintableArticles) { //devo caricare nel prodotto anche tutte le informazioni per il magazzino var locations = warehouseRepository.GetWarehouseList(); ViewBag.Locations = locations; //the new movment display warehouse information //plus new movment in accord to warehouse article specify var cost = docProd.Costs.FirstOrDefault(x => x.CodProductPartPrintableArticle == p.CodProductPartPrintableArticle); // cost. var articles = articleRepository.GetAll(); string codArticle; Article art; var extract = articles.GetArticlesByProductPartPrintableArticle(p); var warehouse = warehouseRepository.GetWarehouseList().OrderBy(x => x.CodWarehouse).FirstOrDefault(); var codWarehouse = warehouse != null ? warehouse.CodWarehouse : ""; var costDetail = cost.CostDetails.FirstOrDefault(); try { if (extract.FirstOrDefault() != null) { art = extract.FirstOrDefault(); if (costDetail != null && costDetail.TypeOfCostDetail == CostDetail.CostDetailType.PrintedRollArticleCostDetail) { //carico i dati EditCost(cost.CodCost); CostDetail temp = (CostDetail)Session["CostDetail"]; var h = temp.PrintingFormat.GetSide1(); art = extract.OfType<RollPrintableArticle>().FirstOrDefault(x => x.Width == h); if (art != null) { codArticle = art.CodArticle; } } if (art != null) { Console.Write(art.CodArticle); var z = warehouseRepository.GetSingleArticle(art.CodArticle, codWarehouse); var newMov = new NewMovViewModel(); newMov.ArticleOrProduct = z; newMov.IsProduct = false; newMov.Mov = new WarehouseArticleMov { WarehouseArticle = z, CodDocument = c.CodDocument, CodProductPartPrintableArticle = p.CodProductPartPrintableArticle, CodWarehouseArticle = z == null ? "" : z.CodWarehouseArticle, Quantity = cost == null ? 0 : art.TransformQuantity(cost.Quantity ?? 0, (CostDetail.QuantityType)(cost.CostDetails.Count() != 0 ? (cost.CostDetails.FirstOrDefault().TypeOfQuantity ?? 10) : 10)), TypeOfMov = 3 }; //ilNewMov.dice del movimento lo prendo dalNewMov.dice dell'articolo newMov.Mov.CodWarehouseArticle = newMov.ArticleOrProduct.CodWarehouseArticle; newMov.Mov.CodWarehouseArticleMov = warehouseRepository.GetNewMovCode(newMov.Mov); warehouseRepository.AddMov(newMov.Mov); warehouseRepository.Save(); warehouseRepository.UpdateArticle(warehouseRepository.GetSingle(newMov.Mov.CodWarehouseArticle)); warehouseRepository.Save(); } } } catch (Exception) { } } } return c; }
public HttpResponseMessage Test( string username, string nCom, string nPrev, string desc, string field1, string field2, string field3, string quantity, string price) { this.Init(); taskCenterRepository.SetDbName(username); productRepository.SetDbName(username); documentRepository.SetDbName(username); //cerco il prodotto ---> se c'è ok //altrimenti lo creo come generico!!! //cerco la commessa ---> se c'è ok //altrimenti la creo var prod = productRepository.GetAll().Where(x => x.PapiroPrev == nPrev).FirstOrDefault(); if (prod == null) { prod = new ProductEmpty(); prod.CodProduct = productRepository.GetNewCode(prod); prod.CodMenuProduct = "Vuoto"; prod.PapiroPrev = nPrev; prod.ProductName = desc; productRepository.Add(prod); productRepository.Save(); } var docProd = documentRepository.GetAllDocumentProducts().Where(x => x.CodProduct == prod.CodProduct).FirstOrDefault(); if (docProd == null) { docProd = new DocumentProduct(); docProd.CodProduct = prod.CodProduct; docProd.UnitPrice = "0";//Convert.ToDouble(price).ToString(); docProd.Quantity = 0; // Convert.ToInt16(quantity); Estimate e = new Estimate(); e.CodDocument = documentRepository.GetNewCode(e); e.EstimateNumberSerie = DateTime.Now.Year.ToString(); e.EstimateNumber = documentRepository.GetNewEstimateNumber(e); //var docProd = documentRepository.GetDocumentProductByCodDocumentProduct(codDocumentProduct); e.DocumentProducts.Add(docProd); documentRepository.Add(e); documentRepository.Save(); docProd.Product = prod; } var c = (Order)documentRepository.GetAll().Where(x => x.PapiroCom == nCom).FirstOrDefault(); if (c == null) { c = new Order(); c.CodDocument = documentRepository.GetNewCode(c); c.OrderNumberSerie = DateTime.Now.Year.ToString(); c.OrderNumber = documentRepository.GetNewOrderNumber(c); c.PapiroCom = nCom; c.OrderProduct = docProd; //c.CodCustomer = docProd.Document.CodCustomer; //c.Customer = docProd.Document.Customer; c.DateDocument = DateTime.Now; var allStates = documentRepository.GetAllStates().Where(x => (x.UseInOrder ?? false)).OrderBy(x => x.StateNumber); foreach (var s in allStates) { c.DocumentStates.Add(new DocumentState { CodDocument = c.CodDocument, StateNumber = s.StateNumber, CodState = s.CodState, // StateName = s.StateName, //derivated!!! ResetLinkedStates = s.ResetLinkedStates, Selected = false }); } documentRepository.Add(c); documentRepository.Save(); //se ci sono dei TaskCenter inizio a buttare i taskcenter nel primo taskcenter (IndexOf==0) var taskCenter = taskCenterRepository.GetAll().Where(y => y.IndexOf == 0).FirstOrDefault(); if (taskCenter != null) { DocumentTaskCenter dtc = new DocumentTaskCenter(); dtc.CodTaskCenter = taskCenter.CodTaskCenter; dtc.CodDocument = c.CodDocument; if (docProd.Product.ProductRefName == null) { dtc.DocumentName = docProd.Product.ProductName; } else { dtc.DocumentName = docProd.Product.ProductRefName; } dtc.FieldA = field1; dtc.FieldB = field2; dtc.FieldC = field3; if (username.ToLower() == "lamarina") { try { dtc.DocumentName = nCom.Substring(0,nCom.IndexOf('/')) + " " + dtc.DocumentName + " " + field1; } catch (Exception) { } dtc.FieldA = ""; } else { dtc.DocumentName = nCom + " " + dtc.DocumentName; } taskCenterRepository.AddNewDocumentTaskCenter(dtc); taskCenterRepository.Save(); } } taskCenterRepository.Dispose(); productRepository.Dispose(); documentRepository.Dispose(); return Request.CreateResponse<string>(HttpStatusCode.OK, username); }