コード例 #1
0
 static void Main(string[] args)
 {
     try
     {
         Application oApp = null;
         if (args.Length < 1)
         {
             oApp = new Application();
         }
         else
         {
             oApp = new Application(args[0]);
         }
         Application.SBO_Application.StatusBar.SetSystemMessage("Start installing UDO's", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
         AddonInfoInfo.InstallUDOs();
         Application.SBO_Application.StatusBar.SetSystemMessage("UDO's installed successfully", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
         Menu MyMenu = new Menu();
         AddonInfoInfo.SetFormFilter();
         Application.SBO_Application.StatusBar.SetSystemMessage("Adding menus", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
         MyMenu.AddMenuItems();
         Application.SBO_Application.StatusBar.SetSystemMessage("Menus Added Successfully", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
         Application.SBO_Application.StatusBar.SetSystemMessage("Register listeners", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
         var bListeners = new ApplicationHandlers();
         Application.SBO_Application.StatusBar.SetSystemMessage("Items Transfer Add-on installed successfully.", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
         oApp.Run();
     }
     catch (Exception ex)
     {
         Utilities.LogException(ex);
     }
 }
コード例 #2
0
 private void Form_DataAddAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
 {
     try
     {
         var ccc = B1Helper.DiCompany.GetNewObjectKey();
         System.Xml.XmlDocument oXmlDoc = new System.Xml.XmlDocument();
         oXmlDoc.LoadXml(pVal.ObjectKey);
         var udoCode = oXmlDoc.SelectSingleNode("//UDO_ItemsTransferParams/DocEntry").InnerText;
         AddonInfoInfo.TransferItemsProcess(Application.SBO_Application, udoCode, SelectedBatchDataSources, SelectedRecBatchDataSources, issTransferItemsList, recTransferItemsList);
     }
     catch (Exception ex)
     {
         Utilities.LogException(ex);
     }
     finally
     {
         ClearListsContents();
         BatchesManaged = null;
     }
 }
コード例 #3
0
        //private async void CalculateCostPercentage()
        //{
        //    try
        //    {
        //        //Action action = new Action(delegate()
        //        //{
        //            double totalWeight = 0;
        //            double totalAmount = 0;
        //            double totalQuantity = 0;

        //            for (int i = 0; i < mtxCost.RowCount; i++)
        //            {
        //                var itmType = ((dynamic)mtxCost.GetCellSpecific("Type", i + 1)).Value;
        //                var itmCost = ((dynamic)mtxCost.GetCellSpecific("Cost", i + 1)).Value;

        //                var itmDoubleCost = itmCost == string.Empty ? 0 : Convert.ToDouble(itmCost);
        //                if (itmType.Equals("Weight"))
        //                    totalWeight += itmDoubleCost;
        //                else if (itmType.Equals("Amount"))
        //                    totalAmount += itmDoubleCost;
        //                else
        //                    totalQuantity += itmDoubleCost;
        //            }

        //            SAPbobsCOM.Items oItem = AddonInfoInfo.GetNewBOneItem();
        //            List<AddonInfoInfo> itemsList = new List<AddonInfoInfo>();

        //            double totalItemsAmount = 0;
        //            double totalItemsAvgPrice = 0;
        //            double totalItemsWeightPrice = 0;
        //            double totalItemQuantity = 0;

        //            for (int i = 0; i < mtxItems.RowCount; i++)
        //            {
        //                var itmCode = ((dynamic)mtxItems.GetCellSpecific("to_Item", i + 1)).Value;
        //                oItem.GetByKey(itmCode);
        //                var oPriceList = oItem.PriceList;
        //                var quantity = ((dynamic)mtxItems.GetCellSpecific("Quantity", i + 1)).Value;
        //                var itmQuantity = Convert.ToDouble(quantity == string.Empty ? 0 : quantity);
        //                var amount = oItem.MovingAveragePrice * Convert.ToDouble(itmQuantity);
        //                var avgPrice = oItem.MovingAveragePrice;
        //                var itemWeight = oItem.PurchaseUnitWeight;

        //                totalItemsAmount += amount;
        //                totalItemsAvgPrice += avgPrice;
        //                totalItemsWeightPrice += itemWeight;
        //                totalItemQuantity += itmQuantity;

        //                var itemInfo = new AddonInfoInfo() { Index = i + 1, ItemWeight = itemWeight, AveragePrice = avgPrice, Amount = amount, Quantity = itmQuantity };
        //                itemsList.Add(itemInfo);
        //            }
        //            var ds = this.UIAPIRawForm.DataSources.DBDataSources.Item(string.Format("@{0}", TableNames.TransferItemsLines));

        //            foreach (var v in itemsList)
        //            {
        //                var itemWeightPercentage = totalItemsWeightPrice == 0 ? 0 : v.ItemWeight * totalWeight / totalItemsWeightPrice;
        //                var itemAmountPercentage = totalItemsAmount == 0 ? 0 : v.Amount * totalAmount / totalItemsAmount;
        //                var itemQuantityPercentage = v.Quantity * totalQuantity / totalItemQuantity;
        //                ds.SetValue("U_AddCost", v.Index - 1, (itemWeightPercentage + itemAmountPercentage + itemQuantityPercentage).ToString());
        //            }
        //            mtxItems.LoadFromDataSource();
        //        //});

        //        //await Task.Run(action);
        //    }
        //    catch (Exception ex)
        //    {
        //        Utilities.LogException(ex);
        //    }
        //}

        private void CalculateCostPercentage()
        {
            try
            {
                //Action action = new Action(delegate()
                //{
                double totalWeight   = 0;
                double totalAmount   = 0;
                double totalQuantity = 0;

                for (int i = 0; i < mtxCost.RowCount; i++)
                {
                    var itmType = ((dynamic)mtxCost.GetCellSpecific("Type", i + 1)).Value;
                    var itmCost = ((dynamic)mtxCost.GetCellSpecific("Cost", i + 1)).Value;

                    var itmDoubleCost = itmCost == string.Empty ? 0 : Convert.ToDouble(itmCost);
                    if (itmType.Equals("Weight"))
                    {
                        totalWeight += itmDoubleCost;
                    }
                    else if (itmType.Equals("Amount"))
                    {
                        totalAmount += itmDoubleCost;
                    }
                    else
                    {
                        totalQuantity += itmDoubleCost;
                    }
                }

                SAPbobsCOM.Items     oItem     = AddonInfoInfo.GetNewBOneItem();
                List <AddonInfoInfo> itemsList = new List <AddonInfoInfo>();

                double totalItemsAmount      = 0;
                double totalItemsAvgPrice    = 0;
                double totalItemsWeightPrice = 0;
                double totalItemQuantity     = 0;

                for (int i = 0; i < mtxItems.RowCount; i++)
                {
                    var itmCode = ((dynamic)mtxItems.GetCellSpecific("to_Item", i + 1)).Value;
                    oItem.GetByKey(itmCode);
                    var oPriceList  = oItem.PriceList;
                    var quantity    = ((dynamic)mtxItems.GetCellSpecific("Quantity", i + 1)).Value;
                    var itmQuantity = Convert.ToDouble(quantity == string.Empty ? 0 : quantity);
                    var amount      = oItem.MovingAveragePrice * Convert.ToDouble(itmQuantity);
                    var avgPrice    = oItem.MovingAveragePrice;
                    var itemWeight  = oItem.PurchaseUnitWeight;

                    totalItemsAmount      += amount;
                    totalItemsAvgPrice    += avgPrice;
                    totalItemsWeightPrice += itemWeight;
                    totalItemQuantity     += itmQuantity;

                    var itemInfo = new AddonInfoInfo()
                    {
                        Index = i + 1, ItemWeight = itemWeight, AveragePrice = avgPrice, Amount = amount, Quantity = itmQuantity
                    };
                    itemsList.Add(itemInfo);
                }
                var ds = this.UIAPIRawForm.DataSources.DBDataSources.Item(string.Format("@{0}", TableNames.TransferItemsLines));

                foreach (var v in itemsList)
                {
                    var itemWeightPercentage   = totalItemsWeightPrice == 0 ? 0 : v.ItemWeight * totalWeight / totalItemsWeightPrice;
                    var itemAmountPercentage   = totalItemsAmount == 0 ? 0 : v.Amount * totalAmount / totalItemsAmount;
                    var itemQuantityPercentage = v.Quantity * totalQuantity / totalItemQuantity;
                    ds.SetValue("U_AddCost", v.Index - 1, (itemWeightPercentage + itemAmountPercentage + itemQuantityPercentage).ToString());
                }
                mtxItems.LoadFromDataSource();
                //});

                //await Task.Run(action);
            }
            catch (Exception ex)
            {
                Utilities.LogException(ex);
            }
        }
コード例 #4
0
        //private async void CalculateCostPercentage()
        //{
        //    try
        //    {
        //        //Action action = new Action(delegate()
        //        //{
        //            double totalWeight = 0;
        //            double totalAmount = 0;
        //            double totalQuantity = 0;

        //            for (int i = 0; i < mtxCost.RowCount; i++)
        //            {
        //                var itmType = ((dynamic)mtxCost.GetCellSpecific("Type", i + 1)).Value;
        //                var itmCost = ((dynamic)mtxCost.GetCellSpecific("Cost", i + 1)).Value;

        //                var itmDoubleCost = itmCost == string.Empty ? 0 : Convert.ToDouble(itmCost);
        //                if (itmType.Equals("Weight"))
        //                    totalWeight += itmDoubleCost;
        //                else if (itmType.Equals("Amount"))
        //                    totalAmount += itmDoubleCost;
        //                else
        //                    totalQuantity += itmDoubleCost;
        //            }

        //            SAPbobsCOM.Items oItem = AddonInfoInfo.GetNewBOneItem();
        //            List<AddonInfoInfo> itemsList = new List<AddonInfoInfo>();

        //            double totalItemsAmount = 0;
        //            double totalItemsAvgPrice = 0;
        //            double totalItemsWeightPrice = 0;
        //            double totalItemQuantity = 0;

        //            for (int i = 0; i < mtxItems.RowCount; i++)
        //            {
        //                var itmCode = ((dynamic)mtxItems.GetCellSpecific("to_Item", i + 1)).Value;
        //                oItem.GetByKey(itmCode);
        //                var oPriceList = oItem.PriceList;
        //                var quantity = ((dynamic)mtxItems.GetCellSpecific("Quantity", i + 1)).Value;
        //                var itmQuantity = Convert.ToDouble(quantity == string.Empty ? 0 : quantity);
        //                var amount = oItem.MovingAveragePrice * Convert.ToDouble(itmQuantity);
        //                var avgPrice = oItem.MovingAveragePrice;
        //                var itemWeight = oItem.PurchaseUnitWeight;

        //                totalItemsAmount += amount;
        //                totalItemsAvgPrice += avgPrice;
        //                totalItemsWeightPrice += itemWeight;
        //                totalItemQuantity += itmQuantity;

        //                var itemInfo = new AddonInfoInfo() { Index = i + 1, ItemWeight = itemWeight, AveragePrice = avgPrice, Amount = amount, Quantity = itmQuantity };
        //                itemsList.Add(itemInfo);
        //            }
        //            var ds = this.UIAPIRawForm.DataSources.DBDataSources.Item(string.Format("@{0}", TableNames.TransferItemsLines));

        //            foreach (var v in itemsList)
        //            {
        //                var itemWeightPercentage = totalItemsWeightPrice == 0 ? 0 : v.ItemWeight * totalWeight / totalItemsWeightPrice;
        //                var itemAmountPercentage = totalItemsAmount == 0 ? 0 : v.Amount * totalAmount / totalItemsAmount;
        //                var itemQuantityPercentage = v.Quantity * totalQuantity / totalItemQuantity;
        //                ds.SetValue("U_AddCost", v.Index - 1, (itemWeightPercentage + itemAmountPercentage + itemQuantityPercentage).ToString());
        //            }
        //            mtxItems.LoadFromDataSource();
        //        //});

        //        //await Task.Run(action);
        //    }
        //    catch (Exception ex)
        //    {
        //        Utilities.LogException(ex);
        //    }
        //}

        private void CalculateCostPercentage()
        {
            try
            {
                //Action action = new Action(delegate()
                //{
                double totalWeight = 0;
                double totalAmount = 0;
                double totalQuantity = 0;

                for (int i = 0; i < mtxCost.RowCount; i++)
                {
                    var itmType = ((dynamic)mtxCost.GetCellSpecific("Type", i + 1)).Value;
                    var itmCost = ((dynamic)mtxCost.GetCellSpecific("Cost", i + 1)).Value;

                    var itmDoubleCost = itmCost == string.Empty ? 0 : Convert.ToDouble(itmCost);
                    if (itmType.Equals("Weight"))
                        totalWeight += itmDoubleCost;
                    else if (itmType.Equals("Amount"))
                        totalAmount += itmDoubleCost;
                    else
                        totalQuantity += itmDoubleCost;
                }

                SAPbobsCOM.Items oItem = AddonInfoInfo.GetNewBOneItem();
                List<AddonInfoInfo> itemsList = new List<AddonInfoInfo>();

                double totalItemsAmount = 0;
                double totalItemsAvgPrice = 0;
                double totalItemsWeightPrice = 0;
                double totalItemQuantity = 0;

                for (int i = 0; i < mtxItems.RowCount; i++)
                {
                    var itmCode = ((dynamic)mtxItems.GetCellSpecific("to_Item", i + 1)).Value;
                    oItem.GetByKey(itmCode);
                    var oPriceList = oItem.PriceList;
                    var quantity = ((dynamic)mtxItems.GetCellSpecific("Quantity", i + 1)).Value;
                    var itmQuantity = Convert.ToDouble(quantity == string.Empty ? 0 : quantity);
                    var amount = oItem.MovingAveragePrice * Convert.ToDouble(itmQuantity);
                    var avgPrice = oItem.MovingAveragePrice;
                    var itemWeight = oItem.PurchaseUnitWeight;

                    totalItemsAmount += amount;
                    totalItemsAvgPrice += avgPrice;
                    totalItemsWeightPrice += itemWeight;
                    totalItemQuantity += itmQuantity;

                    var itemInfo = new AddonInfoInfo() { Index = i + 1, ItemWeight = itemWeight, AveragePrice = avgPrice, Amount = amount, Quantity = itmQuantity };
                    itemsList.Add(itemInfo);
                }
                var ds = this.UIAPIRawForm.DataSources.DBDataSources.Item(string.Format("@{0}", TableNames.TransferItemsLines));

                foreach (var v in itemsList)
                {
                    var itemWeightPercentage = totalItemsWeightPrice == 0 ? 0 : v.ItemWeight * totalWeight / totalItemsWeightPrice;
                    var itemAmountPercentage = totalItemsAmount == 0 ? 0 : v.Amount * totalAmount / totalItemsAmount;
                    var itemQuantityPercentage = v.Quantity * totalQuantity / totalItemQuantity;
                    ds.SetValue("U_AddCost", v.Index - 1, (itemWeightPercentage + itemAmountPercentage + itemQuantityPercentage).ToString());
                }
                mtxItems.LoadFromDataSource();
                //});

                //await Task.Run(action);
            }
            catch (Exception ex)
            {
                Utilities.LogException(ex);
            }
        }