Esempio n. 1
0
        protected void RefreshLogLines(object sender, StoreRefreshDataEventArgs e)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            CommonDomain provider = new CommonDomain();

            List<object> data = new List<object>();
            string[] lines = File.ReadAllLines(string.Format("c:\\Logs\\Advance\\{0}", listFilesSelect.Value.ToString()));
            int lineIndex = 0;
            foreach (string line in lines)
            {
                LogLine logLine = new LogLine(line);
                data.Add(new
                {
                    evTime = logLine.Time.ToString("HH:mm:ss"),
                    evUser = provider.Users.Single(us => us.ID == logLine.UserID).Name,
                    evLevel = logLine.Level,
                    evObject = logLine.Object,
                    evAction = logLine.Action,
                    evIndex = lineIndex
                });
                ++lineIndex;
            }
            logLinesStore.DataSource = data;
            logLinesStore.DataBind();
        }
Esempio n. 2
0
        public static ClassifiacationTypeView GetClassifiacationTypeView(Guid id)
        {
            if (id == FormGridView.ConfigurationTree)
            {
                return ClassifiacationTypeView.ConfigurationTree;
            }
            else if (id == FormGridView.ConfigurationView)
            {
                return ClassifiacationTypeView.ConfigurationView;
            }

            using (CommonDomain domain = new CommonDomain())
            {
                if (domain.ClassificationTrees.Where(c => c.ID == id).Count() > 0)
                {
                    return ClassifiacationTypeView.Standard;
                }
                else if(domain.DictionaryTrees.Where(c => c.ID == id).Count() > 0)
                {
                    return ClassifiacationTypeView.Dictionary;
                }
                else if (domain.CustomClassificationTrees.Where(c => c.ID == id).Count() > 0)
                {
                    return ClassifiacationTypeView.Custom;
                }
            }
            return ClassifiacationTypeView.NotDefined;
        }
Esempio n. 3
0
 public string GetSetting(Guid userID, SettingEnum setting)
 {
     Guid setID  = Setting.GetSettingID(setting);
     using (CommonDomain domain = new CommonDomain())
     {
         UserSetting us = domain.UserSettings.Where(u => u.UserID == userID && u.SettingID == setID).SingleOrDefault();
         if (us == null) return string.Empty;
         else return us.Value;
     }
 }
Esempio n. 4
0
 // добавление конфигураций в мультибуфер
 public void AddConfigurationsToMultiBuffer(IEnumerable<Guid> confids)
 {
     using (CommonDomain domain = new CommonDomain())
     {
         foreach (Guid confid in confids)
         {
             var conf = domain.Configurations.Where(c => c.ID == confid).Single();
             MultiBuffer[conf.ProductID] = conf.ID;
         }
     }
 }
Esempio n. 5
0
 protected string productName(Guid productId)
 {
     using (Aspect.Domain.CommonDomain domain = new Aspect.Domain.CommonDomain())
     {
         var products = from m in domain.Products
                   where m.ID == productId
                   select m;
         if (products.Count() != 1)
         {
             // except:none product of id
             return "";
         }
         else
         {
             return products.First().Name;
         }
     }
 }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (CommonDomain domain = new CommonDomain())
            {
                var usersInfo =
                    from u in domain.Users
                    select new
                    {
                        userID = u.ID,
                        userName = u.Name,
                        userRoles = string.Join(", ",
                            (from ur in domain.UserRoles
                             join r in domain.Roles on ur.RoleID equals r.ID
                             where ur.UserID == u.ID
                             select r.Name).ToArray()
                            )
                    };

                UsersStore.DataSource = usersInfo;
                UsersStore.DataBind();
            }
        }
Esempio n. 7
0
 public void SaveSetting(Guid userID, SettingEnum setting, string value)
 {
     Guid setID = Setting.GetSettingID(setting);
     using (CommonDomain domain = new CommonDomain())
     {
         UserSetting us = domain.UserSettings.Where(u => u.UserID == userID && u.SettingID == setID).SingleOrDefault();
         if (us == null)
         {
             us = new UserSetting();
             us.ID = Guid.NewGuid();
             us.UserID = userID;
             us.SettingID = setID;
             us.Value = value;
             domain.UserSettings.InsertOnSubmit(us);
             domain.SubmitChanges();
         }
         else
         {
             us.Value = value;
             domain.SubmitChanges();
         }
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Копирование продукта внутри того же класса с заданием
        /// новой версии. Копируются внешние и внутренние свойства 
        /// продукта. Можно указать новое значение словаря _dictNomen.
        /// </summary>
        /// <param name="oldProductID"></param>
        /// <param name="newVersion"></param>
        /// <returns>Guid созданного при копировании продукта</returns>
        public Guid CopyProduct(Guid oldProductID, int newVersion, Guid newDictNomen, Guid userID)
        {
            /* создать запись в dbo.Products */
            Guid newProductID;
            Product newProduct, oldProduct;

            using (CommonDomain commonDomain = new CommonDomain())
            {
                // копируем запись в таблице Product
                oldProduct = commonDomain.Products.SingleOrDefault(p => p.ID == oldProductID);
                newProductID = commonDomain.AddNewProduct(oldProductID, true, Guid.Empty.Equals(newDictNomen) ? oldProduct._dictNomenID.Value : newDictNomen, userID);
                newProduct = commonDomain.Products.SingleOrDefault(p => p.ID == newProductID);

                // копируем ссылки на словари
                newProduct._dictNomen1ID = oldProduct._dictNomen1ID;
                newProduct._dictPVDID = oldProduct._dictPVDID;
                newProduct._dictSFID = oldProduct._dictSFID;
                newProduct._dictUMID = oldProduct._dictUMID;

                /*newProduct.cod_Asp = oldProduct.cod_Asp;
                newProduct.cod_Nomen_Asp = oldProduct.cod_Nomen_Asp;
                newProduct.cod_Nomen1_Asp = oldProduct.cod_Nomen1_Asp;*/
                commonDomain.SubmitChanges();
            }

            /* скопировать все поля в dbo.ProductProperty */
            using (CommonDomain domain = new CommonDomain())
            {
                List<ProductProperty> props = domain.ProductProperties.Where(p => p.ProductID == oldProductID).ToList();
                foreach (ProductProperty prop in props)
                {
                    ProductProperty newProp = new ProductProperty();
                    newProp.ID = Guid.NewGuid();
                    newProp.PropertyID = prop.PropertyID;
                    newProp.ProductID = newProduct.ID;
                    newProp.Value = prop.Value;
                    if (prop.PropertyID == new Guid("BBE170B0-28E4-4738-B365-1038B03F4552")) // основная версия
                    {
                        newProp.Value = "0";
                    }
                    if (prop.PropertyID == new Guid("0789DB1A-9BAA-4574-B405-AE570C746C03")) // версия
                    {
                        newProp.Value = newVersion.ToString();
                    }
                    if (prop.PropertyID == new Guid("3EA753C8-2B06-41DA-B3DB-421D110B079E")) // дата изменения продукта
                    {
                        // управляется триггером
                        continue;
                    }
                    domain.ProductProperties.InsertOnSubmit(newProp);
                }
                domain.SubmitChanges();
            }

            /* вернуть ID созданного продукта */
            return newProductID;
        }
Esempio n. 9
0
 /// <summary>
 /// Копирование всей спецификации из одного продукта в другой
 /// </summary>
 public void CopyConfiguration(Guid fromProductID, Guid toProductID, Guid UserID)
 {
     // копирование по аналогу вместе с составом
     using (CommonDomain domain = new CommonDomain())
     {
         var confs = from p in domain.Configurations
                     where p.ProductOwnerID == fromProductID
                     select p;
         foreach (Aspect.Domain.Configuration conf in confs)
         {
             Aspect.Domain.Configuration confRow = new Aspect.Domain.Configuration();
             confRow.AutoUpdate = conf.AutoUpdate;
             confRow.Comment = conf.Comment;
             confRow.GroupNumber = conf.GroupNumber;
             confRow.GroupToChange = conf.GroupToChange;
             confRow.Position = conf.Position;
             confRow.Quantity = conf.Quantity;
             confRow.QuantityInclusive = conf.QuantityInclusive;
             confRow.Zone = conf.Zone;
             confRow._dictUMID = conf._dictUMID;
             confRow.dt_upd = conf.dt_upd;
             if (Guid.Empty.Equals(conf.UserID))
             {
                 confRow.UserID = UserID;
             }
             else
             {
                 confRow.UserID = conf.UserID;
             }
             confRow.ID = Guid.NewGuid();
             confRow.ProductOwnerID = toProductID;
             confRow.ProductID = conf.ProductID;
             domain.Configurations.InsertOnSubmit(confRow);
         }
         domain.SubmitChanges();
     }
 }
Esempio n. 10
0
        public static string RequestDicts(string dicts)
        {
            using (CommonDomain domain = new CommonDomain())
            {
                string[] required_dicts = dicts.Split(',');
                Dicts list_dicts = new Dicts();

                if (required_dicts.Contains("pvd"))
                {
                    foreach (var item in domain._dictPVDs.OrderBy(d => d.pvdn))
                    {
                        list_dicts.PVDs.Add(new DictItem()
                        {
                            ID = item.ID,
                            Name = item.pvdn
                        });
                    }
                }
                if (required_dicts.Contains("um"))
                {
                    foreach (var item in domain._dictUMs.OrderBy(d => d.umn1))
                    {
                        list_dicts.UMs.Add(new DictItem()
                        {
                            ID = item.ID,
                            Name = item.umn1
                        });
                    }
                }
                if (required_dicts.Contains("sf"))
                {
                    foreach (var item in domain._dictSFs.OrderBy(d => d.sfn))
                    {
                        list_dicts.SFs.Add(new DictItem()
                        {
                            ID = item.ID,
                            Name = item.sfn
                        });
                    }
                }
                if (required_dicts.Contains("s"))
                {
                    foreach (var item in domain._dicts.OrderBy(d => d.so))
                    {
                        list_dicts.Ss.Add(new DictItem()
                        {
                            ID = item.id,
                            Name = item.sn1
                        });
                    }
                }
                if (required_dicts.Contains("ste"))
                {
                    foreach (var item in domain._dictS_tes.OrderBy(d => d.type))
                    {
                        list_dicts.STEs.Add(new DictItem()
                        {
                            ID = item.id,
                            Name = item.type
                        });
                    }
                }
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                return serializer.Serialize(list_dicts);
            }
        }
Esempio n. 11
0
        private void DataLoad()
        {
            List<ITreeNode> parents = new List<ITreeNode>();
            using (CommonDomain domain = new CommonDomain())
            {
                parents = domain.GetProductParents(this.RequestProductID);

                Aspect.Domain.Product prod = domain.GetProduct(this.RequestProductID);

                if (prod == null) return;
                this.Title = HeaderLiteral.Text = string.Format("Редактирование {0} Версия {1}", prod.PublicName, prod.Version == null ? string.Empty : prod.Version.ToString());
                if (this.IsNew) this.Title = HeaderLiteral.Text = string.Format("Добавление по аналогу {0} Версия {1}", prod.PublicName, prod.Version == null ? string.Empty : prod.Version.ToString());
                HeaderDateLiteral.Text = string.Format(HeaderDateLiteral.Text, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString());

                BindGeneralPropertyList(parents);
                BindDictionaryList(parents);
            }
        }
Esempio n. 12
0
        protected void Save_Click(object sender, EventArgs e)
        {
            this.Validate();
            if (this.IsValid)
            {
                // Проверяем, является ли продукт основной версией
                ProductProvider productProvider = new ProductProvider();
                if (productProvider.IsMainVersion(this.ProductID))
                {
                    LabelErrorMessage.Text = "[ ! ] Содержащий данную спецификацию продукт является основной версией. Сохранение отменено.";
                    return;
                }

                JavaScriptSerializer js = new JavaScriptSerializer();
                List<Dictionary<string, string>> rows = js.Deserialize<List<Dictionary<string, string>>>(hiddenStoreData.Value.ToString());
                EditConfigurationProvider provider = new EditConfigurationProvider();
                List<GridColumn> gridColumns = provider.GetGridColumns();

                // Сохраняем данные, полученные от пользователя в списке конфигураций
                List<Aspect.Domain.Configuration> result = new List<Aspect.Domain.Configuration>();
                #region convert Request to list of Configuration
                foreach (Dictionary<string, string> row in rows)
                {
                    Guid productID = new Guid(row["ID"]);
                    Aspect.Domain.Configuration conf = new Aspect.Domain.Configuration();
                    conf.ID = new Guid(row["ConfID"]);
                    conf.ProductID = productID;
                    conf.ProductOwnerID = this.ProductID;
                    conf.UserID = this.User.ID;

                    foreach (GridColumn column in gridColumns)
                    {
                        if (column is EditableGridColumn)
                        {
                            System.Reflection.PropertyInfo prop = typeof(Aspect.Domain.Configuration).GetProperty(column.DataItem);
                            if (prop.PropertyType == typeof(decimal) || prop.PropertyType == typeof(Nullable<decimal>))
                            {
                                prop.SetValue(conf, Convert.ToDecimal(row[column.DataItem]), null);
                            }
                            else if (prop.PropertyType == typeof(int) || prop.PropertyType == typeof(Nullable<int>))
                            {
                                prop.SetValue(conf, Convert.ToInt32(row[column.DataItem]), null);
                            }
                            else if (prop.PropertyType == typeof(Guid) || prop.PropertyType == typeof(Nullable<Guid>))
                            {
                                prop.SetValue(conf, new Guid(row[column.DataItem]), null);
                            }
                            else if (prop.PropertyType == typeof(Boolean) || prop.PropertyType == typeof(Nullable<Boolean>))
                            {
                                prop.SetValue(conf, Convert.ToBoolean(row[column.DataItem]), null);
                            }
                            else
                            {
                                prop.SetValue(conf, row[column.DataItem], null);
                            }
                        }
                    }

                    result.Add(conf);
                }
                #endregion

                using (CommonDomain domain = new CommonDomain())
                {
                    // Проверка на включение материалов
                    #region check_including_material
                    foreach (Aspect.Domain.Configuration conf in result)
                    {
                        Product prod = domain.Products.Single(p => p.ID == conf.ProductID);
                        if (prod._dictNomen.cod >= 1000000)
                        {
                            LabelErrorMessage.Text = "[ ! ] Обнаружены материалы в спецификации. Сохранение отменино.";
                            return;
                        }
                    }
                    #endregion

                    // Проверка на циклы
                    #region check_for_cycles
                    Guid dictNomenID = (Guid) (from p in domain.Products
                                               where p.ID == this.ProductID
                                               select p).Single()._dictNomenID;
                    foreach (Aspect.Domain.Configuration conf in result)
                    {
                        Product prod = domain.Products.Where(p => p.ID == conf.ProductID).Single();
                        if (dictNomenID == prod._dictNomenID)
                        {
                            LabelErrorMessage.Text = "[ ! ] Обнаружены циклические включения продуктов в спецификацию. Сохранение отменино.";
                            return;
                        }
                        if (fnCheckContains(dictNomenID, prod.ID))
                        {
                            LabelErrorMessage.Text = "[ ! ] Обнаружены циклические включения продуктов в спецификацию. Сохранение отменино.";
                            return;
                        }
                    }
                    #endregion
                }

                provider.SaveProductConfiguration(this.ProductID, result, this.User.ID);

                // установка признака "Основная версия"
                if (MadeBasicVersion.Checked)
                {
                    productProvider.SetMainVersion(this.User.ID, new List<Guid>{ProductID});
                }

                // устанавливаем основание изменений
                if (!String.IsNullOrEmpty(ReasonChanges.Text))
                {
                    ProductProperty reasonProperty = productProvider.ProductProperties.SingleOrDefault(
                        pr => pr.PropertyID == new Guid("C266B994-9740-41F6-94DD-07EA5B5FA34A")
                        && pr.ProductID == this.ProductID);

                    if (reasonProperty == null)
                    {
                        reasonProperty = new ProductProperty()
                        {
                            ID = Guid.NewGuid(),
                            PropertyID = new Guid("C266B994-9740-41F6-94DD-07EA5B5FA34A"),
                            ProductID = this.ProductID,
                            Value = ReasonChanges.Text
                        };
                        productProvider.ProductProperties.InsertOnSubmit(reasonProperty);
                    }
                    else
                    {
                        reasonProperty.Value = ReasonChanges.Text;
                    }
                    productProvider.SubmitChanges();
                }

                // Очищаем сообщение об ошибке и обновляем данные о спецификации
                LabelErrorMessage.Text = "";
                this.BindGridColumns2();
                this.BindData(new Dictionary<Guid, Guid>());
            }
        }
Esempio n. 13
0
 protected bool fnCheckContains(Guid dictNomenID, Guid whereProduct)
 {
     using (CommonDomain domain = new CommonDomain())
     {
         List<Aspect.Domain.Configuration> confs;
         confs = (from conf in domain.Configurations
                 where conf.ProductOwnerID == whereProduct
                 select conf).ToList();
         foreach (Aspect.Domain.Configuration conf in confs)
         {
             if (conf.Product._dictNomenID == dictNomenID) return true;
             if (fnCheckContains(dictNomenID, conf.ProductID)) return true;
         }
         return false;
     }
 }
Esempio n. 14
0
 public PermissionProvider(CommonDomain domain)
 {
     DBDomain = domain;
 }
Esempio n. 15
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            //if (this.IsNew)
            //{
                string version = null;
                string nomenValue = null;
                CustomValidator validator1 = null;
                CustomValidator validator2 = null;
                #region Get the @version
                foreach (RepeaterItem item in GeneralPropertyRepeater.Items)
                {
                    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                    {
                        Guid id = new Guid((item.FindControl("HiddenID") as HiddenField).Value);
                        if (id == new Guid("0789DB1A-9BAA-4574-B405-AE570C746C03"))
                        {
                            EditControl editControl = item.FindControl("PropertyValueAdv") as EditControl;
                            if (!editControl.Validate()) return;
                            version = editControl.Value.ToString().Trim();
                            //version = (item.FindControl("PropertyValue") as TextBox).Text.Trim();
                            validator1 = item.FindControl("UniqueValueValidator") as CustomValidator;
                        }
                    }
                }
                #endregion
                #region Get the @nomenValue
                foreach (RepeaterItem item in DictionaryPropertyRepeater.Items)
                {
                    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                    {
                        Guid dictId = new Guid((item.FindControl("HiddenTreeID") as HiddenField).Value);
                        if (dictId == new Guid("316C6BC7-D883-44C8-AAE0-602F49C73595"))
                        {
                            nomenValue = (item.FindControl("HiddenID") as HiddenField).Value;
                            validator2 = item.FindControl("UniqueValueValidator") as CustomValidator;
                        }
                    }
                }
                #endregion
                #region Check the unique @version && @nomenValue
                if (version != null && nomenValue != null && validator1 != null && validator2 != null)
                {
                    using (ProductProvider provider = new ProductProvider())
                    {
                        var q = from p in provider.Products
                                join pp in provider.ProductProperties on p.ID equals pp.ProductID
                                where pp.PropertyID == new Guid("0789DB1A-9BAA-4574-B405-AE570C746C03") //&& p.ID == this.RequestProductID
                                && pp.Value == version && p._dictNomenID == new Guid(nomenValue)
                                select p;
                        List<Product> list = q.ToList();
                        if (list.Count > 0 && this.IsNew)
                        {
                            validator1.IsValid = false;
                            validator2.IsValid = false;
                            return;
                        }
                        else if (list.Count > 0 && list.Where(p => p.ID == this.RequestProductID).Count() == 0)
                        {
                            validator1.IsValid = false;
                            validator2.IsValid = false;
                            return;
                        }
                    }
                }
                else
                {
                    return;
                }
                #endregion
                #region Check the main version canceling...
                string mainVersionValue = null;
                CustomValidator mainVersionValidator = null;
                foreach (RepeaterItem item in GeneralPropertyRepeater.Items)
                {
                    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                    {
                        Guid id = new Guid((item.FindControl("HiddenID") as HiddenField).Value);
                        if (id == new Guid("bbe170b0-28e4-4738-b365-1038b03f4552"))
                        {
                            EditControl editControl = item.FindControl("PropertyValueAdv") as EditControl;
                            if (!editControl.Validate()) return;
                            mainVersionValue = editControl.Value.ToString().Trim();
                            mainVersionValidator = item.FindControl("UniqueValueValidator") as CustomValidator;
                        }
                    }
                }
                if (mainVersionValue != null && mainVersionValidator != null && !this.IsNew)
                {
                    using (ProductProvider provider = new ProductProvider())
                    {
                        var q = from p in provider.ProductProperties
                                where p.PropertyID == new Guid("bbe170b0-28e4-4738-b365-1038b03f4552")
                                && p.ProductID == this.RequestProductID
                                select p;
                        List<ProductProperty> list = q.ToList();
                        if (list.Count == 1)
                        {
                            // попытка изменить основную версию
                            if (list.First().Value == "1")
                            {
                                mainVersionValidator.IsValid = false;
                                return;
                            }
                        }
                    }
                }
                #endregion
                //}
            if (this.IsNew)
            {
                using (ProductProvider provider = new ProductProvider())
                {
                    Guid newID = provider.AddNewProduct(this.RequestProductID, User.ID);
                    if (this.IsWithConfs)
                    {
                        // копирование по аналогу вместе с составом
                        provider.CopyConfiguration(this.RequestProductID, newID, this.User.ID);
                    }
                    newProductID = newID;
                }
            }

            using (ProductProvider provider = new ProductProvider())
            {
                Product editedProduct = provider.GetProduct(RequestProductID);
                if (editedProduct.userID != User.ID)
                {
                    editedProduct.userID = User.ID;
                    provider.SubmitChanges();
                }
            }

            #region update dictionary values
            using (DictionaryProvider provider = new DictionaryProvider())
            {
                foreach (RepeaterItem item in DictionaryPropertyRepeater.Items)
                {
                    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                    {
                        Guid dictId = new Guid((item.FindControl("HiddenTreeID") as HiddenField).Value);
                        string valueString = (item.FindControl("HiddenID") as HiddenField).Value;
                        DictionaryTree dict = provider.DictionaryTrees.Single(d => d.ID == dictId);
                        if (!string.IsNullOrEmpty(valueString) && !(new Guid(valueString).Equals(Guid.Empty)))
                        {
                            provider.SetProductDictioanryValue(this.RequestProductID, dict.FK, valueString.Trim(), User.ID);
                        }
                        else
                        {
                            provider.DeleteProductDictionaryValue(this.RequestProductID, dict.FK, User.ID);
                        }
                    }
                }
                provider.SubmitChanges();
            }
            #endregion

            #region update properties values
            using (ProductProvider provider = new ProductProvider())
            {
                bool settingMainVersion = false;

                foreach (RepeaterItem item in GeneralPropertyRepeater.Items)
                {
                    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                    {
                        Guid id = new Guid((item.FindControl("HiddenID") as HiddenField).Value);
                        //string value = (item.FindControl("PropertyValue") as TextBox).Text.Trim();
                        EditControl editControl = item.FindControl("PropertyValueAdv") as EditControl;
                        if (!editControl.IsEmpty && !editControl.Validate())
                        {
                            continue;
                        }

                        // Если поле "Вес по приказу" не заполнено, то заполняем его из номенклатуры
                        if (id == new Guid("AC37F816-E4C1-4751-99ED-6180D7CCA142") && editControl.IsEmpty)
                        {
                            Product prod = provider.GetProduct(this.RequestProductID);
                            if (prod._dictNomen.pw.HasValue)
                            {
                                editControl.Value = prod._dictNomen.pw.Value.ToString(CultureInfo.InvariantCulture).Replace(".", ",");
                            }

                        }

                        if (editControl.IsEmpty)
                        {
                            ProductProperty prop = provider.ProductProperties.SingleOrDefault(pp => pp.PropertyID == id && pp.ProductID == this.RequestProductID);
                            if (prop != null)
                            {
                                provider.ProductProperties.DeleteOnSubmit(prop);
                                provider.SubmitChanges();
                            }
                            continue;
                        }

                        string value = editControl.Value.ToString().Trim();
                        if (editControl.ControlType == TypeEnum.Datetime)
                        {
                            DateTime dt = DateTime.ParseExact(value, "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture);
                            if (dt == DateTime.MinValue) value = string.Empty;
                            else value = dt.ToString("yyyy-MM-dd hh:mm:ss.fff");
                        }

                        // установка признака "Основная версия"
                        if (id == new Guid ("BBE170B0-28E4-4738-B365-1038B03F4552") && value == "1")
                        {
                            settingMainVersion = true;
                        }

                        ProductProperty property = provider.ProductProperties.SingleOrDefault(pp => pp.PropertyID == id && pp.ProductID == this.RequestProductID);
                        if (property != null)
                        {
                            if (property.Value != value)
                            {
                                Aspect.Utility.TraceHelper.Log(User.ID, "Продукт: {0}. Свойство изменино: {1}. Старое значение {2}. Новое значение {3}", this.RequestProductID, property.Property.Name, property.Value, value);
                            }
                            property.Value = value;
                        }
                        else
                        {
                            property = new ProductProperty()
                            {
                                ID = Guid.NewGuid(),
                                ProductID = this.RequestProductID,
                                PropertyID = id,
                                Value = value
                            };
                            provider.ProductProperties.InsertOnSubmit(property);
                            Property prop = provider.Properties.Single(p => p.ID == id);
                            Aspect.Utility.TraceHelper.Log(User.ID, "Продукт: {0}. Свойство изменино: {1}. Старое значение NULL. Новое значение {2}", this.RequestProductID, prop.Name, value);
                        }
                        provider.SubmitChanges();
                    }
                }

                // Переносим вес из продуктов в _dictNomen, если там он отсутствует (0 или null)
                if (settingMainVersion)
                {
                    try
                    {
                        // Пытаемся получить свойство с весом если оно есть
                        string raw_pw = (from p in provider.Products
                                      join pp in provider.ProductProperties on p.ID equals pp.ProductID
                                      where p.ID == this.RequestProductID && pp.PropertyID == new Guid("AC37F816-E4C1-4751-99ED-6180D7CCA142")
                                      select pp.Value).Single();
                        decimal prod_pw = Convert.ToDecimal(raw_pw.Replace(',', '.'), CultureInfo.InvariantCulture);

                        // Если свойство есть переносим его
                        if (prod_pw != 0)
                        {
                            _dictNomen dict = (from p in provider.Products
                                               join d in provider._dictNomens on p._dictNomenID equals d.ID
                                               where p.ID == this.RequestProductID
                                               select d).Single();
                            dict.pw = prod_pw;
                            provider.SubmitChanges();
                        }
                    }
                    catch
                    {
                        // перехватываем исключение, так как веса у продукта может вовсе и не быть
                    }
                }
            }
            #endregion

            if (this.IsNew)
            {
                // добавить свойство "пустой состав"
                if (!this.IsWithConfs)
                {
                    using (CommonDomain provider = new CommonDomain())
                    {
                        var properties = from props in provider.ProductProperties
                                         where props.PropertyID == new Guid("00ACC1C7-6857-4317-8713-8B8D9479C5CC") // Свойство "Наличие состава"
                                         && props.ProductID == RequestProductID
                                         select props;

                        if (properties.Count() > 1)
                        {
                            // если несколько одинаковых свойств - генерируем исключение
                            throw new Exception("У продукта не может быть больше одного свойства \"Наличие состава\"!");
                        }
                        else if (properties.Count() == 1)
                        {
                            // если только одно свойство - редактируем его, и сохраняемся
                            properties.First().Value = "-";
                        } else
                        {
                            // если нет ниодного свойства, создаём его с нужным нам значеним
                            provider.ProductProperties.InsertOnSubmit(new ProductProperty()
                            {
                                ID = Guid.NewGuid(),
                                ProductID = RequestProductID,
                                PropertyID = new Guid("00ACC1C7-6857-4317-8713-8B8D9479C5CC"),
                                Value = "-"
                            });

                        }
                        provider.SubmitChanges();
                    }
                }

                // перенаправить на редактирование
                Response.Redirect(string.Format("Edit.aspx?ID={0}", this.RequestProductID));
                return;
            }
            if(Page.IsValid) this.DataLoad();
        }
Esempio n. 16
0
        /// <summary>
        /// Row of kmhCard -> tran
        /// </summary>
        protected static void FillKmhByRow(CommonDomain provider, DataRow kmhRow, transfer tran, DateTime currentDT)
        {
            string postfix = "";
            if (kmhRow.Field<Guid?>("id1").HasValue)
            {
                // карточка приказная
                postfix = "1";
                tran.isprikaz = true;
            }
            else
            {
                // карточка стандартная
                if (!kmhRow.Field<Guid?>("id").HasValue)
                {
                    // нет никакой карточки
                    return;
                }
            }

            tran.material_id = kmhRow.Field<Guid?>("_Material_ID" + postfix);
            if (tran.material_id != null)
            {
                tran.material = kmhRow.Field<string>("MaterialSuperpole" + postfix);
            }

            tran.sw = kmhRow.Field<decimal?>("sw" + postfix);
            tran.stw = kmhRow.Field<decimal?>("stw" + postfix);

            tran.ss = kmhRow.Field<string>("ss" + postfix);
            tran.sp = kmhRow.Field<string>("sp" + postfix);
            tran.sd = kmhRow.Field<string>("sd" + postfix);

            /*tran.gotov_him = kmhRow.Field<string>("h_got" + postfix).Trim() == "ГОТОВ" ? true : false;
            tran.gotov_tech = kmhRow.Field<string>("t_got" + postfix).Trim() == "ГОТОВ" ? true : false;
            tran.gotov_svar = kmhRow.Field<string>("s_got" + postfix).Trim() == "ГОТОВ" ? true : false;*/

            tran.gotov_him = kmhRow.Field<DateTime?>("him_date" + postfix).HasValue;
            tran.gotov_tech = kmhRow.Field<DateTime?>("techn_date" + postfix).HasValue;
            tran.gotov_svar = kmhRow.Field<DateTime?>("svar_date" + postfix).HasValue;

            /*tran.gotov_him = kmhRow.Field<DateTime?>("him_date" + postfix).HasValue;
            tran.gotov_tech = kmhRow.Field<DateTime?>("techn_date" + postfix).HasValue;
            tran.gotov_svar = kmhRow.Field<DateTime?>("svar_date" + postfix).HasValue;*/

            tran.no = kmhRow.Field<decimal?>("no" + postfix);
            tran.cmt_ogt = kmhRow.Field<string>("cmt" + postfix);
            tran.route = kmhRow.Field<string>("Route" + postfix) == null ? "" : kmhRow.Field<string>("Route" + postfix).Trim();

            tran.pvd_id = kmhRow.Field<Guid?>("_dictPVDID" + postfix);
            tran.um_id = kmhRow.Field<Guid?>("_dictUMID" + postfix);
            tran.sf_id = kmhRow.Field<Guid?>("_dictSFID" + postfix);
            tran.ste_id = kmhRow.Field<Guid?>("_dictS_TEID" + postfix);

            /*tran.pvd_id = kmhCard._dictPVDID;
            tran.pvd = tran.pvd_id == null ? "" : kmhCard._dictPVD.pvdn;
            tran.um_id = kmhCard._dictUMID;
            tran.um = tran.um_id == null ? "" : kmhCard._dictUM.umn1;
            tran.sf_id = kmhCard._dictSFID;
            tran.sf = tran.sf_id == null ? "" : kmhCard._dictSF.sfn;

            tran.ste_id = kmhCard._dictS_TEID;
            tran.ste = tran.ste_id == null ? "" : kmhCard._dictS_te.type;*/

            tran.actual = (kmhRow.Field<DateTime>("StartDT" + postfix) < currentDT && kmhRow.Field<DateTime>("FinishDT" + postfix) > currentDT);

            if (!String.IsNullOrEmpty(kmhRow.Field<string>("RouteForChange")))
            {
                // заменяем маршрут из карточки на маршрут по применяемости
                tran.route = kmhRow.Field<string>("RouteForChange");
                tran.route_changed = true;
            }
            tran.last_change_date = kmhRow.Field<DateTime?>("dtle" + postfix);

            /*if (kmhRow.Field<DateTime?>("dtle" + postfix).HasValue)
            {
                tran.last_change_date = kmhRow.Field<DateTime?>("dtle" + postfix).Value;
            }
            else
            {
                tran.last_change_date = DateTime.MinValue;
            }*/
            tran.last_change_user = kmhRow.Field<string>("Name" + postfix);
            //tran.isprikaz = !(kmhCard.OrderArticleID == null);
        }
Esempio n. 17
0
 public TreeQuery(CommonDomain provider)
     : base(provider)
 {
 }
Esempio n. 18
0
        private void BindData()
        {
            using (Aspect.Domain.CommonDomain domain = new Aspect.Domain.CommonDomain())
            {

                List<Aspect.Domain.Configuration> RightConfigurations = domain.Configurations.Where(c => c.ProductOwnerID == ProductID1).ToList();
                List<Aspect.Domain.Configuration> LeftConfigurations = domain.Configurations.Where(c => c.ProductOwnerID == ProductID2).ToList();

                ConfListComparer comparer = new ConfListComparer(LeftConfigurations, RightConfigurations);

                DataSet dataSet1 = new DataSet();
                DataSet dataSet2 = new DataSet();

                BindDataSetCollumns(ref dataSet1);
                BindDataSetCollumns(ref dataSet2);

                /* Сортировка по HSO */
                var hso = from h in domain._dictHs
                          orderby h.hso ascending
                          select h.hso;

                foreach (int hsID in hso)
                {
                    /* добавление одинаковых записей */
                    foreach (Aspect.Domain.Configuration conf in (from item in comparer.listIdential1 where item.Product._dictNomen._dictH.hso == hsID select item))
                    {
                        BindDataSetField(ref dataSet1, conf, ConfType.Normal, new Aspect.Domain.Configuration());
                    }

                    foreach (Aspect.Domain.Configuration conf in (from item in comparer.listIdential2 where item.Product._dictNomen._dictH.hso == hsID select item))
                    {
                        BindDataSetField(ref dataSet2, conf, ConfType.Normal, new Aspect.Domain.Configuration());
                    }

                    /* добавление изменившихся записей */
                    foreach (Aspect.Domain.Configuration conf in (from item in comparer.listChanged2 where item.Product._dictNomen._dictH.hso == hsID select item))
                    {
                        BindDataSetField(ref dataSet1, conf, ConfType.Changed, new Aspect.Domain.Configuration());
                    }

                    foreach (Aspect.Domain.Configuration conf in (from item in comparer.listChanged1 where item.Product._dictNomen._dictH.hso == hsID select item))
                    {
                        BindDataSetField(ref dataSet2, conf, ConfType.Changed, new Aspect.Domain.Configuration());
                    }

                    /* добавление уникальных записей */
                    foreach (Aspect.Domain.Configuration conf in (from item in comparer.listUnical1 where item.Product._dictNomen._dictH.hso == hsID select item))
                    {
                        BindDataSetField(ref dataSet1, conf, ConfType.Newed, comparer.getAlternate1(conf.ID));
                        BindDataSetField(ref dataSet2, conf, ConfType.Nulled, new Aspect.Domain.Configuration());
                    }

                    foreach (Aspect.Domain.Configuration conf in (from item in comparer.listUnical2 where item.Product._dictNomen._dictH.hso == hsID select item))
                    {
                        BindDataSetField(ref dataSet2, conf, ConfType.Newed, comparer.getAlternate2(conf.ID));
                        BindDataSetField(ref dataSet1, conf, ConfType.Nulled, new Aspect.Domain.Configuration());
                    }
                }

                LeftGridView.DataSource = dataSet1;
                LeftGridView.DataBind();

                RightGridView.DataSource = dataSet2;
                RightGridView.DataBind();
            }
        }