public void OpenStockTransferForm() { try { if (!Object.ReferenceEquals(requestTransfers, null)) { LogService.WriteInfo("Begin Transfer for Document: " + requestTransfers[0].DocNum); SAPMatrix.SetColumnQuantities(mtx0, "Quantity", requestTransfers, "Quantity"); requestTransfers[0].Observations = txtObserv.Value; var result = StockTransferDI.CreateDraft(requestTransfers, user); if (result.Success) { Form form = SAPbouiCOM.Framework.Application.SBO_Application.OpenForm((BoFormObjectEnum)112, "", result.DocEntry.ToString()); this.UIAPIRawForm.Close(); Task.Factory.StartNew(() => { AlertMessageDI.Create(new MessageDTO() { UserCode = foodTransferDAO.GetUserCode(requestTransfers[0].UserID.ToString()), Message = "Se ha realizado la transferencia de mercancia solicitada en el documento #" + requestTransfers[0].DocNum }); }); LogService.WriteInfo("End Transfer for Document: " + requestTransfers[0].DocNum); } else { UIApplication.ShowMessageBox(result.Message); } } } catch (Exception ex) { SAPException.Handle(ex, "OpenStockTransferForm"); } }
private void mtx0_ClickAfter(object sboObject, SBOItemEventArg pVal) { try { if (!SelectRow(mtx0, pVal.Row)) { return; } string docNum = dt0.GetValue("C_Folio", selectedRow - 1).ToString(); string docEntry = pendingTransfers.Where(t => t.Folio == docNum).FirstOrDefault().DocEntry.ToString(); transferItems = foodTransferDAO.GetTransferItems(docEntry); Task.Factory.StartNew(() => { this.UIAPIRawForm.Freeze(true); SAPMatrix.Fill("DT1", dt1, mtx1, columns1.Keys.ToList(), transferItems); seriesNumbers = foodTransferDAO.GetSeriesNumbers(docEntry); this.UIAPIRawForm.Freeze(false); }); } catch (AggregateException ae) { ae.Handle(e => { SAPException.Handle(e, "mtx0_ClickAfter(AggregateException)"); return(true); }); } }
public frmTransfer() { try { Task.Factory.StartNew(FillMatrix0); Task.Run(() => PrepareMatrix1()); } catch (AggregateException ae) { ae.Handle(e => { SAPException.Handle(e, "Constructor"); return(true); }); } }
private void CreateTransfer(bool isCancellation) { var transferDocument = new DocumentTransfer(); try { LogService.WriteInfo("Begin Create Transfer"); transferDocument.Document = pendingTransfers[selectedRow - 1]; transferDocument.Lines = transferItems; transferDocument.Series = seriesNumbers; if (!String.IsNullOrEmpty(txtComment.Value)) { transferDocument.Document.Comments = txtComment.Value; } Task.Factory.StartNew(() => { return(StockTransferDI.CreateTransfer(transferDocument, isCancellation)); }).ContinueWith(t => { if (t.Result.Success) { pendingTransfers = foodTransferDAO.GetPendingTransfers(); this.UIAPIRawForm.Freeze(true); SAPMatrix.Fill("DT0", dt0, mtx0, columns0.Keys.ToList(), pendingTransfers); this.UIAPIRawForm.Freeze(false); if (isCancellation) { AlertMessageDI.Create(new MessageDTO() { UserCode = foodTransferDAO.GetUserCode(transferDocument.Document.UserID.ToString()), Message = String.Format("Se ha rechazado la transferencia #{0} y se ha solicitado la trasnferencia de devolución #{1}", transferDocument.Document.Folio, t.Result.DocEntry) }); } SAPMatrix.ClearMtx(mtx1); transferItems = null; seriesNumbers = null; transferDocument = null; } UIApplication.ShowMessageBox(t.Result.Message); LogService.WriteInfo("End Create Transfer"); }); } catch (AggregateException ae) { ae.Handle(e => { SAPException.Handle(e, "CreateTransfer"); return(true); }); } }
public frmProcess() { try { user = new User(""); user.FormID = this.UIAPIRawForm.UniqueID; EnableButtons(false); Parallel.Invoke(PrepareMatrix, LoadEvents, user.IsFoodPlant == true ? new Action(InitFoodPlant) : new Action(InitQuarantine)); } catch (AggregateException ae) { ae.Handle(e => { SAPException.Handle(e, "frmProcess"); return(true); }); } }
private void Form_ResizeAfter(SBOItemEventArg pVal) { try { if (resize) { UIAPIRawForm.Freeze(true); mtx0.Item.Height = UIAPIRawForm.Height / 2 - 100; mtx1.Item.Top = UIAPIRawForm.Height / 2 - 50; mtx1.Item.Height = mtx0.Item.Height; UIAPIRawForm.Freeze(false); } else { resize = true; } } catch (Exception ex) { SAPException.Handle(ex, "Form_ResizeAfter"); } }
private void CreateDocuments(bool cancellation) { try { //Validations if (!ValidateColumn("Existence") || !ValidateColumn("Emision")) { return; } if (!cancellation && !ValidateColumn("BagBales")) { return; } //Setting the Bags/Bales values and Real Quantity SetBagsBalesAndRealQuantity(); //Transaction BeginTransaction(); LogService.WriteInfo("Begin " + (cancellation ? "cancellation" : "Production") + " Process"); //Invetory Exit var task = Task.Factory.StartNew(() => { var exit = new DocumentProduction(); exit.Lines = !cancellation ? components : new Component[1] { productionLine }; exit.DocEntry = docEntry; exit.DocNum = txtFolio.Value; return(StockExitDI.CreateDocument(exit, user, cancellation)); }); task.Wait(); if (!user.IsFoodPlant && !cancellation) { productionLine.LineTotal = task.Result.DocTotal; } //Inventory Entry var task2 = Task.Factory.StartNew(() => { if (!cancellation) { productionLine.Qty = components.Where(c => c.Prod.Equals(0)).Sum(s => s.Qty); } var entry = new DocumentProduction(); entry.Lines = !cancellation ? new Component[1] { productionLine } : components; entry.DocEntry = docEntry; entry.DocNum = txtFolio.Value; return(StockEntryDI.CreateDocument(entry, user, cancellation)); }); var task3 = Task.Factory.ContinueWhenAll(new[] { task, task2 }, _ => { var resultMessage = (!cancellation) ? new StringBuilder() .Append("Entrada de Producto Terminado: ").AppendLine(task2.Result.Message) .Append("Salida de Componentes: ").AppendLine(task.Result.Message) : new StringBuilder() .Append("Salida de Producto Terminado: ").AppendLine(task.Result.Message) .Append("Entrada de Componentes: ").AppendLine(task2.Result.Message); if (task.Result.Success && task2.Result.Success) { if (user.IsFoodPlant && !cancellation) { //Update Status to Closed for Production Order Document var result = ProductionOrderDI.CancelDocument(docEntry, task2.Result.DocEntry, task.Result.DocEntry); resultMessage.Append("Orden de Fabricación: ").AppendLine(result.Message); } if (cancellation) { var result = InventoryRevaluationDI.CreateDocument(productionLine, user, task.Result.DocEntry, docEntry); if (result.Success) { resultMessage.Append("Revalorización de Inventario: ").AppendLine(result.Message); } } if (StockEntryDI.UpdateDocument(task2.Result.DocEntry, task.Result.DocEntry, cancellation)) { Commit(); } else { RollBack(resultMessage.ToString()); } } else { RollBack(resultMessage.ToString()); } UIApplication.ShowMessageBox(resultMessage.ToString()); ClearMatrix(); if (user.IsFoodPlant && cancellation) { SAPChooseFromList.AddConditionValues(this.UIAPIRawForm.ChooseFromLists.Item("CFL_PO"), "DocNum", foodTransferDAO.GetCancelledOrders(user.WhsCode)); } else if (!user.IsFoodPlant && !cancellation) { txtFolio.Value = foodTransferDAO.GetSeries(user.WhsCode, "59", "NextNumber").ToString(); //OIGN } }); LogService.WriteInfo("Begin " + (cancellation ? "cancellation" : "Production") + " Process"); } catch (Exception ex) { SAPException.Handle(ex, "CreateDocuments"); } }
private void chkStatus_ClickAfter(object sboObject, SBOItemEventArg pVal) { try { var checkBox = (CheckBox)sboObject; //FOOD PLANT ---------------------------------------------------------------------------------------- if (user.IsFoodPlant) { if (!checkBox.Checked) { SAPChooseFromList.AddConditionValues(this.UIAPIRawForm.ChooseFromLists.Item("CFL_PO"), "DocNum", foodTransferDAO.GetCancelledOrders(user.WhsCode)); } else { SAPChooseFromList.AddConditions(this.UIAPIRawForm.ChooseFromLists.Item("CFL_PO"), new Dictionary <string, string>() { { "Type", "S" }, { "Status", "R" }, { "Warehouse", "PLHE" } }); } } //QUARANTINE ---------------------------------------------------------------------------------------- else { txtBags.Active = true; //Stock Entry's if (!checkBox.Checked) { txtFolio.Item.Enabled = true; txtItem.Item.Enabled = false; if (this.UIAPIRawForm.ChooseFromLists.Count < 3) { LoadChooseFromList2("CFL_SE", "59", new Dictionary <string, string>() { { "Series", foodTransferDAO.GetSeries(user.WhsCode, "59", "Series").ToString() }, { "U_GLO_InMo", "E-PROD" }, { "U_GLO_Status", "O" } }, txtFolio); } else { SAPChooseFromList.Bind("CFL_SE", txtFolio); } txtFolio.Active = true; btnCreate.Item.Enabled = false; } //Material List's else { txtFolio.Item.Enabled = false; txtItem.Item.Enabled = true; SAPChooseFromList.Bind("CFL_ML", txtItem); txtItem.Active = true; } } //-------------------------------------------------------------------------------------------------- txtFolio.Active = true; mtx0.Columns.Item("C_Consumed").Visible = !checkBox.Checked ? true : false; mtx0.Columns.Item("C_Qty").Visible = !checkBox.Checked ? false : true; mtx0.Columns.Item("C_Bags").Editable = !checkBox.Checked ? false : true; ClearMatrix(); if (!user.IsFoodPlant && checkBox.Checked) { txtFolio.Value = foodTransferDAO.GetSeries(user.WhsCode, "59", "NextNumber").ToString(); } } catch (Exception ex) { SAPException.Handle(ex, "chkStatus_ClickAfter"); } }
private void SBO_Application_ItemEvent(string FormUID, ref ItemEvent pVal, out bool BubbleEvent) { BubbleEvent = true; try { if (FormUID.Equals(this.UIAPIRawForm.UniqueID)) { if (!pVal.BeforeAction) { switch (pVal.EventType) { case BoEventTypes.et_CHOOSE_FROM_LIST: try { if (String.IsNullOrEmpty(SAPChooseFromList.GetValue(pVal, 0))) { return; } txtBags.Item.Enabled = chkStatus.Checked ? false : true; if (user.IsFoodPlant) { //FOOD PLANT---------------------------- btnCreate.Item.Enabled = !chkStatus.Checked ? true : false; btnCancel.Item.Enabled = chkStatus.Checked ? true : false; docEntry = int.Parse(SAPChooseFromList.GetValue(pVal, 0)); txtItem.Value = SAPChooseFromList.GetValue(pVal, 48); txtDate.Value = SAPDate.ParseDate(SAPChooseFromList.GetValue(pVal, 9).Substring(0, 10)).ToString("yyyyMMdd"); this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_PO").ValueEx = SAPChooseFromList.GetValue(pVal, 1); SetProductionItem(SAPChooseFromList.GetValue(pVal, 3), txtItem.Value, Double.Parse(SAPChooseFromList.GetValue(pVal, 7)), !chkStatus.Checked ? 0 : foodTransferDAO.GetProdItemBags(docEntry)); components = foodTransferDAO.GetComponents(SAPChooseFromList.GetValue(pVal, 0), user.WhsCode, false); plannedQty = GetPlannedQty(docEntry); txtQPlan.Value = plannedQty.ToString(); if (chkStatus.Checked && productionLine.Bags > 0) { txtBags.Value = productionLine.Bags.ToString("#.####"); } else if (chkStatus.Checked && productionLine.Bags <= 0) { txtBags.Value = "0.0000"; } Task.Run(() => { FillMatrix(); CalculateQuantities(components, plannedQty); }); } else //QUARANTINE-------------------------- //Material List { if (pVal.ItemUID == "txtItem") { btnCreate.Item.Enabled = true; this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_ML").ValueEx = SAPChooseFromList.GetValue(pVal, 24); SetProductionItem(SAPChooseFromList.GetValue(pVal, 0), txtItem.Value, Double.Parse(SAPChooseFromList.GetValue(pVal, 3)), 0); components = foodTransferDAO.GetComponents(SAPChooseFromList.GetValue(pVal, 0), user.WhsCode, chkStatus.Checked); } //Stock Entry else if (pVal.ItemUID == "txtFolio") { btnCancel.Item.Enabled = true; docEntry = int.Parse(SAPChooseFromList.GetValue(pVal, 0)); txtDate.Value = SAPDate.ParseDate(SAPChooseFromList.GetValue(pVal, 10).Substring(0, 10)).ToString("yyyyMMdd"); this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_SE").ValueEx = SAPChooseFromList.GetValue(pVal, 1); productionLine = foodTransferDAO.GetProductionItem(docEntry, user.WhsCode); txtItem.Value = productionLine.Desc; components = foodTransferDAO.GetComponents(SAPChooseFromList.GetValue(pVal, 458), user.WhsCode, chkStatus.Checked); } Task.Run(() => { FillMatrix(); txtQReal.Value = !chkStatus.Checked ? SAPMatrix.SumColumnQuantities(mtx0, "C_Qty", components).ToString() : productionLine.Qty.ToString(); }); } } catch (Exception ex) { SAPException.Handle(ex, "SBO_Application_ItemEvent"); } break; case SAPbouiCOM.BoEventTypes.et_LOST_FOCUS: if (pVal.ColUID == "C_Qty") { if (user.IsFoodPlant) { CalculateQuantities(components, plannedQty); } else { txtQReal.Value = SAPMatrix.SumColumnQuantities(mtx0, pVal.ColUID, components).ToString(); } } break; } } }//Event for date picker else if (String.IsNullOrEmpty(pVal.ItemUID) && pVal.FormType == 10000075 && !user.IsFoodPlant) { if (this.UIAPIRawForm.Selected) { switch (pVal.EventType) { case SAPbouiCOM.BoEventTypes.et_FORM_CLOSE: if (pVal.ActionSuccess) { SAPDate.ValidateDate(txtDate, 3); } break; } } } } catch (Exception ex) { SAPException.Handle(ex, "SBO_Application_ItemEvent"); } }