Esempio n. 1
0
        public void Save(Model.ItemGroupModel itemGroupModel)
        {
            int groupCode = Controller.ConnectionController.Instance.ExecuteSqlForObject <int>("GetItemGroupCode", itemGroupModel.GroupName);

            if (groupCode != 0)
            {
                itemGroupModel.GroupCode = groupCode;
                return;
            }

            ItemGroups itemGroup = (ItemGroups)Controller.ConnectionController.Instance.Company.GetBusinessObject(BoObjectTypes.oItemGroups);

            try
            {
                if (itemGroup.GetByKey(itemGroupModel.GroupCode))
                {
                    itemGroup.GroupName = itemGroupModel.GroupName;

                    foreach (KeyValuePair <string, dynamic> userField in itemGroupModel.UserFields)
                    {
                        itemGroup.UserFields.Fields.Item(userField.Key).Value = userField.Value;
                    }

                    Controller.ConnectionController.Instance.VerifyBussinesObjectSuccess();

                    itemGroup.Update();
                }
                else
                {
                    itemGroup.GroupName = itemGroupModel.GroupName;
                    //itemGroup.InventoryAccount = "1.01.01.01.01";
                    //itemGroup.CostAccount = "1.01.01.01.01";
                    //itemGroup.TransfersAccount = "1.01.01.01.01";
                    //itemGroup.VarianceAccount = "1.01.01.01.01";
                    //itemGroup.PriceDifferencesAccount = "1.01.01.01.01";

                    foreach (KeyValuePair <string, dynamic> userField in itemGroupModel.UserFields)
                    {
                        itemGroup.UserFields.Fields.Item(userField.Key).Value = userField.Value;
                    }

                    itemGroup.Add();

                    Controller.ConnectionController.Instance.VerifyBussinesObjectSuccess();

                    itemGroupModel.GroupCode = Controller.ConnectionController.Instance.LastObjectCode;
                }
            }
            finally
            {
                GC.Collect();
                Marshal.ReleaseComObject(itemGroup);
            }
        }
Esempio n. 2
0
        public void Save()
        {
            if (_newObject)
            {
                _businessObject.Add();
            }
            else
            {
                _businessObject.Update();
            }

            Controller.ConnectionController.Instance.VerifyBussinesObjectSuccess();

            if (m_ItemClassSet)
            {
                Controller.ConnectionController.Instance.ExecuteStatementDirect(@"UPDATE OITB SET ""ItemClass"" = '{0}' WHERE ""ItmsGrpCod"" = {1}", ((int)ItemClassEnum.itcMaterial).ToString(), _businessObject.Number.ToString());

                m_ItemClassSet = false;
            }

            if (m_MaterialTypeSet)
            {
                Controller.ConnectionController.Instance.ExecuteStatementDirect(@"UPDATE OITB SET ""MatType"" = '{0}' WHERE ""ItmsGrpCod"" = {1}", ((int)m_MaterialType).ToString(), _businessObject.Number.ToString());

                m_MaterialTypeSet = false;
            }

            if (m_MaterialGroupSet)
            {
                Controller.ConnectionController.Instance.ExecuteStatementDirect(@"UPDATE OITB SET ""MatGrp"" = '{0}' WHERE ""ItmsGrpCod"" = {1}", m_MaterialGroup.ToString(), _businessObject.Number.ToString());

                m_MaterialGroupSet = false;
            }

            if (m_NCMCodeSet)
            {
                Controller.ConnectionController.Instance.ExecuteStatementDirect(@"UPDATE OITB SET ""NCMCode"" = '{0}' WHERE ""ItmsGrpCod"" = {1}", m_NCMCodeSet.ToString(), _businessObject.Number.ToString());

                m_NCMCodeSet = false;
            }

            if (m_ProductSourceSet)
            {
                Controller.ConnectionController.Instance.ExecuteStatementDirect(@"UPDATE OITB SET ""ProductSrc"" = '{0}' WHERE ""ItmsGrpCod"" = {1}", m_ProductSource.ToString(), _businessObject.Number.ToString());

                m_ProductSourceSet = false;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Adds the item to the index.
        /// </summary>
        public void AddToIndex(object item, int itemKey)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            TKey indexKey = GetIndexKey(item);

            if (!ItemGroups.TryGetValue(indexKey, out IndexGroup group))
            {
                group = new IndexGroup();
                ItemGroups.Add(indexKey, group);
            }

            group[itemKey] = (TItem)item;
        }
Esempio n. 4
0
        /// <summary>
        /// Adds the item to the index.
        /// </summary>
        public void AddToIndex(object item, int itemKey)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            int indexKey = GetIndexKey(item);

            if (!ItemGroups.TryGetValue(indexKey, out SortedDictionary <int, object> group))
            {
                group = new SortedDictionary <int, object>();
                ItemGroups.Add(indexKey, group);
            }

            group[itemKey] = item;
        }
Esempio n. 5
0
        public void Load(int algorithmNum)
        {
            Num = algorithmNum;
            using (XmlReader reader = XmlReader.Create(Paths.DataPath + "FloorAlgorithm\\" + algorithmNum + ".xml")) {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.Name)
                        {
                        case "Name": {
                            Name = reader.ReadString();
                            break;
                        }

                        case "FloorSetting": {
                            if (reader.Read())
                            {
                                string settingName = reader.ReadElementString("FloorInt");
                                bool   settingBool = reader.ReadElementString("FloorIntBool").ToBool();
                                FloorSettings.Add(new Tuple <string, bool>(settingName, settingBool));
                            }
                        }
                        break;

                        case "LayerSetting": {
                            LayerSettings.Add(reader.ReadString());
                        }
                        break;

                        case "TileSetting": {
                            TileSettings.Add(reader.ReadString());
                        }
                        break;

                        case "FoliageSetting": {
                            FoliageSettings.Add(reader.ReadString());
                        }
                        break;

                        case "CoverSetting": {
                            CoverSettings.Add(reader.ReadString());
                        }
                        break;

                        case "ItemGroup": {
                            ItemGroups.Add(reader.ReadString());
                        }
                        break;

                        case "NpcGroup": {
                            NpcGroups.Add(reader.ReadString());
                        }
                        break;

                        case "RoomGroup": {
                            RoomGroups.Add(reader.ReadString());
                        }
                        break;
                        }
                    }
                }
            }
        }