private void NewTask() { WMSServiceClient serv = new WMSServiceClient(); DocumentType docType = new DocumentType { DocClass = new DocumentClass { DocClassID = SDocClass.Task } }; docType.DocTypeID = SDocType.CountTask; // CAA [2010/05/05] Valida que se incluyan las columnas necesarias en el reporte // Indica si utiliza Product para la programacion del conteo. bool useProduct = true; if (cboToDo.SelectedIndex == 0) //Only BIN { useProduct = false; if (!products.Columns.Contains("BinCode")) { Util.ShowError("BinCode column missing."); return; } } else if (cboToDo.SelectedIndex == 1) // BIN & PRODUCT { if (!products.Columns.Contains("BinCode") || !products.Columns.Contains("Product")) { Util.ShowError("BinCode and/or Product columns are missing."); return; } } Document document = new Document { DocType = docType, CrossDocking = false, IsFromErp = false, Location = App.curLocation, Company = App.curCompany, Date1 = DateTime.Today, CreationDate = DateTime.Now, CreatedBy = App.curUser.UserName, Notes = cboToDo.SelectedIndex.ToString() }; document = serv.CreateNewDocument(document, true); // SaveDocument(document); // Details foreach (DataRow row in products.Rows) { // ojo... siempre deben enviar los alias "producto" "binCode" en el reporte !!! Product prod = null; try { if (!string.IsNullOrEmpty(row["Product"].ToString()) && useProduct) prod = serv.GetProduct(new Product { ProductCode = row["Product"].ToString() })[0]; } catch { } Bin bin = null; try { if (!string.IsNullOrEmpty(row["BinCode"].ToString())) bin = serv.GetBin(new Bin { BinCode = row["BinCode"].ToString() })[0]; } catch { } //Crea el BinTask en el server BinByTask binByTask = new BinByTask { CreatedBy = App.curUser.UserName, CreationDate = DateTime.Now, Bin = bin, Product = prod, TaskDocument = document, Status = new Status { StatusID = DocStatus.New } }; try { serv.SaveBinByTask(binByTask); } catch { continue; } } Util.ShowMessage("Counting Task " + document.DocNumber + " was created."); ClosePopup(); }