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); }); } }
private void CalculateQuantities(Component[] components, double plannedQty) { var realQty = !chkStatus.Checked ? SAPMatrix.SumColumnQuantities(mtx0, "C_Qty", components) : CalculateConsumedQty(components); txtQReal.Value = !chkStatus.Checked ? realQty.ToString() : productionLine.Qty.ToString(); txtQDif.Value = CalculateDifferenceQty(realQty, plannedQty).ToString("#.####"); }
public void PrepareMatrix() { columns = new Dictionary <string, BoFieldsType>() { { "#", BoFieldsType.ft_ShortNumber }, { "Item", BoFieldsType.ft_AlphaNumeric }, { "Desc", BoFieldsType.ft_AlphaNumeric }, { "Quantity", BoFieldsType.ft_Quantity } }; dt0 = SAPMatrix.CreateDataTable("DT0", columns, this); SAPMatrix.Fill("DT0", dt0, mtx0, columns.Keys.ToList(), requestTransfers); }
public void PrepareMatrix1() { columns1 = new Dictionary <string, BoFieldsType>() { { "#", BoFieldsType.ft_ShortNumber }, { "Item", BoFieldsType.ft_AlphaNumeric }, { "Desc", BoFieldsType.ft_AlphaNumeric }, { "Quantity", BoFieldsType.ft_AlphaNumeric }, { "Bags", BoFieldsType.ft_Float } }; dt1 = SAPMatrix.CreateDataTable("DT1", columns1, this); mtx1.AutoResizeColumns(); }
private void btnCancel_ClickBefore(object sboObject, SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; if (btnCancel.Item.Enabled) { SAPMatrix.SetColumnQuantities(mtx0, "Consumed", components, "Qty"); CreateDocuments(true); } }
private void PrepareMatrix() { columns = new Dictionary <string, BoFieldsType>() { { "#", BoFieldsType.ft_ShortNumber }, { "Item", BoFieldsType.ft_AlphaNumeric }, { "Desc", BoFieldsType.ft_AlphaNumeric }, { "Whs", BoFieldsType.ft_AlphaNumeric }, { "Exist", BoFieldsType.ft_Quantity }, { "Plan", BoFieldsType.ft_Quantity }, { "Qty", BoFieldsType.ft_Quantity }, { "Consumed", BoFieldsType.ft_Quantity }, { "Bags", BoFieldsType.ft_Float } }; dt0 = SAPMatrix.CreateDataTable("dt0", columns, this); mtx0.Columns.Item("C_Consumed").Visible = false; mtx0.AutoResizeColumns(); }
private void mtx0_ClickAfter(object sboObject, SBOItemEventArg pVal) { SelectRow(mtx0, pVal.Row); transferItems = foodPlantDAO.GetTransferItems(dt0.GetValue("C_Folio", selectedRow - 1).ToString()); Task.Factory.StartNew(() => { this.UIAPIRawForm.Freeze(true); SAPMatrix.Fill("DT1", dt1, mtx1, columns1.Keys.ToList(), transferItems); this.UIAPIRawForm.Freeze(false); }); }
private void SetBagsBalesAndRealQuantity() { SAPMatrix.SetColumnQuantities(mtx0, "Bags", components, "Bags"); if (!chkStatus.Checked && !String.IsNullOrEmpty(txtBags.Value)) { productionLine.Bags = Double.Parse(txtBags.Value); } productionLine.Qty = Double.Parse(txtQReal.Value); }
public void FillMatrix0() { columns0 = new Dictionary <string, BoFieldsType>() { { "#", BoFieldsType.ft_ShortNumber }, { "Folio", BoFieldsType.ft_AlphaNumeric }, { "DocDate", BoFieldsType.ft_AlphaNumeric }, { "Comments", BoFieldsType.ft_AlphaNumeric } }; dt0 = SAPMatrix.CreateDataTable("DT0", columns0, this); pendingTransfers = foodTransferDAO.GetPendingTransfers(); this.UIAPIRawForm.Freeze(true); SAPMatrix.Fill("DT0", dt0, mtx0, columns0.Keys.ToList(), pendingTransfers); this.UIAPIRawForm.Freeze(false); }
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); }); } }
private void btnCreate_ClickBefore(object sboObject, SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; if (btnCreate.Item.Enabled) { SAPMatrix.SetColumnQuantities(mtx0, "Qty", components, "Qty"); if (components.Where(l => l.Qty == 0).Count() == components.Length) { return; } CreateDocuments(false); } }
public void ClearMatrix() { txtBags.Value = String.Empty; txtItem.Value = String.Empty; txtDate.Value = String.Empty; txtQDif.Value = String.Empty; txtQPlan.Value = String.Empty; txtQReal.Value = String.Empty; txtFolio.Value = String.Empty; this.UIAPIRawForm.Freeze(true); SAPMatrix.ClearMtx(mtx0); this.UIAPIRawForm.Freeze(false); components = null; productionLine = new Component(); docEntry = 0; plannedQty = 0; EnableButtons(false); }
private void FillMatrix() { this.UIAPIRawForm.Freeze(true); SAPMatrix.Fill("dt0", dt0, mtx0, columns.Keys.ToList(), components); this.UIAPIRawForm.Freeze(false); }
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"); } }