예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (ProductProvider provider = new ProductProvider())
     {
         Product product = provider.GetProduct(new Guid(Request.Params["prodid"]));
         Page.Title = String.Format("Применяемость по изделиям для {0} версии {1}",
                 product.Name,
                 product.Version);
     }
 }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (ProductProvider provider = new ProductProvider())
     {
         // ищем продукт в приказных изделиях
         Product product = provider.GetProduct(new Guid(Request[PROD_ID]));
         if (!String.IsNullOrEmpty(product.OrderNumber) && !String.IsNullOrEmpty(product.OrderYear))
         {
             // приказное изделия
             var orders = from order in provider.OrderArticles
                          where order.year == product.OrderYear
                          && order.cco == product.OrderNumber
                          select order;
             if (orders.Count() > 0)
             {
                 // есть приказ соотвествующий номеру и году
                 Page.Title = string.Format("Разузлованный технологический состав для {0} версии {1}. Номер приказа: {2}. Год приказа: {3}",
                     product._dictNomen.pn1,
                     product.Version,
                     product.OrderNumber,
                     product.OrderYear);
             }
             else
             {
                 // приказа нет, поэтому будем считать его стандартным
                 Page.Title = string.Format("Разузлованный технологический состав для {0} стандартной версии {1}.",
                     product._dictNomen.pn1,
                     product.Version);
             }
         }
         else
         {
             // не приказное изделие
             Page.Title = string.Format("Разузлованный технологический состав для {0} стандартной версии {1}.",
                 product._dictNomen.pn1,
                 product.Version);
         }
     }
 }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (ProductProvider provider = new ProductProvider())
            {
                Product product = provider.GetProduct(new Guid(Request.QueryString["prodid"]));

                if (Request.QueryString["orderid"] == null)
                {
                    Title = String.Format("Редактирование %state% КМХ для {0}.", product.PublicName);
                }
                else
                {
                    OrderArticle order = (from or in provider.OrderArticles
                                         where or.ID == new Guid(Request.QueryString["orderid"])
                                         select or).Single();
                    Title = String.Format("Редактирование %state% КМХ для {0}. По приказу №{1} от {2} года.", product.PublicName, order.cco, order.year);
                }
            }

            this.PopupIframeInitializationStringWithProduct(linkSelectMaterial, "",
                string.Format("../Popup/Selector.aspx?ID={0}&ctrlID={1}&treeID={2}&textCtrlID={3}",
                "", "valueID", "316c6bc7-d883-44c8-aae0-602f49c73595", "clientID"), 800, 500);
        }
예제 #4
0
        public static string SaveRoute2(transfer saved_route)
        {
            using (ProductProvider provider = new ProductProvider())
            {
                Guid unitDictNomen = (saved_route.unit_id == Guid.Empty) ? Guid.Empty : provider.GetProduct(saved_route.unit_id)._dictNomenID.Value;
                Guid prodDictNomen = provider.GetProduct(saved_route.prod_id)._dictNomenID.Value;

                SaveRouteInternal(unitDictNomen, prodDictNomen, saved_route.route);
            };

            return new PostResult("ok", 0).ToString();
        }
예제 #5
0
        public static string RequestKmhCard(Guid prod_id, Guid order_id)
        {
            using (ProductProvider provider = new ProductProvider())
            {
                DateTime CurDateTime = DateTime.Now;
                Product prod = provider.GetProduct(prod_id);
                transfer tran = new transfer() { prod_id = prod._dictNomenID.Value };

                #region filling kmh card
                if (Guid.Empty.Equals(order_id))
                {
                    var actual_kmh = from kmh in provider.Specification_1s
                                     where kmh.OrderArticleID == null // стандарные (не приказные)
                                     && kmh.StartDT <= CurDateTime // на текущую дату
                                     && kmh.FinishDT > CurDateTime
                                     && kmh._Product_ID == prod._dictNomenID
                                     select kmh;

                    if (actual_kmh.Count() > 0)
                    {
                        FillKmh(actual_kmh.First(), tran, CurDateTime);
                        tran.prod_pn2 = actual_kmh.First().Product.superpole;
                    }
                    else
                    {
                        // создание новой КМХ для продукта
                        tran.prod_id = prod._dictNomenID.Value;
                        tran.prod_pn2 = prod._dictNomen.superpole;
                    }
                }
                else
                {
                    Product order_unit = provider.GetActualOrderProduct(order_id);
                    Specification_1 actual_kmh = null;

                    // пытаемся получить КМХ для данного приказа
                    try
                    {
                        actual_kmh = (from kmh in provider.Specification_1s
                                      where kmh.OrderArticleID == order_id // стандарные (не приказные)
                                      && kmh.StartDT <= CurDateTime // на текущую дату
                                      && kmh.FinishDT > CurDateTime
                                      && kmh._Product_ID == prod._dictNomenID
                                      select kmh).Single();
                    }
                    catch
                    {
                        // пытаемся получить КМХ на момент создания сборки
                        try
                        {
                            var actual_date = (from dates in provider.TechnDates
                                               where dates.OrderArticleID == order_id
                                               && dates._dictNomenID == prod._dictNomenID
                                               select dates.gen_date).SingleOrDefault();
                            if (actual_date == null) actual_date = order_unit.CreatedDate;

                            actual_kmh = (from kmh in provider.Specification_1s
                                          where kmh.OrderArticleID == null // стандарные (не приказные)
                                          && kmh.StartDT <= actual_date
                                          && kmh.FinishDT > actual_date
                                          && kmh._Product_ID == prod._dictNomenID
                                          select kmh).Single();
                        }
                        catch
                        {
                        }
                    }

                    if (actual_kmh == null)
                    {
                        // создание новой КМХ для продукта
                        tran.prod_id = prod._dictNomenID.Value;
                        tran.prod_pn2 = prod._dictNomen.superpole;
                    }
                    else
                    {
                        // заполняем карточку
                        FillKmh(actual_kmh, tran, CurDateTime);
                        tran.prod_pn2 = actual_kmh.Product.superpole;
                    }
                }
                #endregion

                Guid userID = (Guid)HttpContext.Current.Session["userID"];
                List<Guid> userRoles = (from role in provider.UserRoles
                                        where role.UserID == userID
                                        select role.RoleID).ToList();

                var permisions = (from perm in provider.RoleViewPermissions
                                 where perm.PermissionEntityID == new Guid("11F1BC17-20FB-4E93-8389-A55BFA4CA251") // EditorKMH
                                 && userRoles.Contains(perm.RoleID)
                                 && perm.Read
                                 select perm.EntityID).Distinct();

                tran.enabled_fields.AddRange(permisions);

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                return serializer.Serialize(tran);
            }
        }
예제 #6
0
        public static string RequestAllRoutes(Guid prod_id)
        {
            using (ProductProvider provider = new ProductProvider())
            {
                DateTime currentDT = DateTime.Now;

                List<transfer_route> list_routes = new List<transfer_route>();
                Product product = provider.GetProduct(prod_id);

                var applicability = (from conf in provider.Configurations
                                    join prod in provider.Products on conf.ProductID equals prod.ID
                                    join ownprod in provider.Products on conf.ProductOwnerID equals ownprod.ID
                                    join ownnomen in provider._dictNomens on ownprod._dictNomenID equals ownnomen.ID
                                    where prod._dictNomenID == product._dictNomenID
                                    select ownnomen.ID).Distinct();

                var all_routes = from route in provider.Specification_3s
                                 where route._Material_ID == product._dictNomenID
                                 && route.StartDT <= currentDT
                                 && route.FinishDT > currentDT
                                 select route;

                // есть применяемость
                // нет маршрута
                var list1 = applicability.Where(appl => !all_routes.Any(rt => rt._Product_ID == appl));
                foreach (Guid ownnomen_id in list1)
                {
                    _dictNomen ownnomen = provider._dictNomens.SingleOrDefault(d => d.ID == ownnomen_id);

                    transfer_route adding_route = new transfer_route();
                    adding_route.prodNomenID = product._dictNomenID.Value;
                    adding_route.unitNomenID = ownnomen.ID;
                    adding_route.unit_pn1 = ownnomen.pn1;
                    adding_route.unit_pn2 = ownnomen.superpole;
                    list_routes.Add(adding_route);
                }

                // есть маршрут
                foreach (Specification_3 route in all_routes )
                {
                    try
                    {
                        _dictNomen unit_nomen = provider._dictNomens.SingleOrDefault(d => d.ID == route._Product_ID);

                        transfer_route adding_route = new transfer_route();
                        adding_route.ID = route.id;
                        adding_route.prodNomenID = product._dictNomenID.Value;
                        adding_route.unitNomenID = route._Product_ID;
                        adding_route.unit_pn1 = unit_nomen.pn1;
                        adding_route.unit_pn2 = unit_nomen.superpole;
                        adding_route.route = route.Route;
                        adding_route.comment = route.cmt;
                        adding_route.lastedit_date = route.dtle;

                        try
                        {
                            adding_route.lastedit_author = (from u in provider.Users
                                                            where u.ID == route.userID
                                                            select u.Name).Single();
                        } catch {};

                        list_routes.Add(adding_route);
                    }
                    catch { }
                }

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                return serializer.Serialize(list_routes);
            }
        }
예제 #7
0
        public static string RequestAddMaterials(Guid prod_id, Guid order_id)
        {
            DateTime CurDateTime = DateTime.Now;

            using (ProductProvider provider = new ProductProvider())
            {
                // пытаемся получить приказные доп. материалы для данного приказа
                Product prod = provider.GetProduct(prod_id);

                // пытаемся получить временные метки для химика, сварщика и технолога
                DateTime himDate = DateTime.Now, svarDate = DateTime.Now, technDate = DateTime.Now;
                var dateLabels = provider.TechnDates.SingleOrDefault(it
                    => it._dictNomenID == prod._dictNomenID
                    && it.OrderArticleID == order_id);

                // временные метки учитываются только для приказных составов
                if (dateLabels != null && order_id != Guid.Empty)
                {
                    himDate = dateLabels.him_date.HasValue ? dateLabels.him_date.Value : dateLabels.gen_date.Value;
                    technDate = dateLabels.techn_date.HasValue ? dateLabels.techn_date.Value : dateLabels.gen_date.Value;
                    svarDate = dateLabels.svar_date.HasValue ? dateLabels.svar_date.Value : dateLabels.gen_date.Value;
                }

                // получаем отдельно приказные материалы для химика, сварщика и технолога
                #region request him kmh
                var him_kmh = from kmh in provider.Specification_2s
                                    where (kmh.OrderArticleID == order_id)
                                        && kmh.StartDT <= CurDateTime
                                        && kmh.FinishDT > CurDateTime
                                        && kmh._Product_ID == prod._dictNomenID
                                        && kmh._dictS_TEID == new Guid("46A00C26-1768-4521-9A33-88336E65D50C")
                                    select kmh;
                if (him_kmh.Count() == 0)
                {
                    him_kmh = from kmh in provider.Specification_2s
                                    where kmh.OrderArticleID == null
                                        && kmh.StartDT <= himDate
                                        && kmh.FinishDT > himDate
                                        && kmh._Product_ID == prod._dictNomenID
                                    select kmh;
                }
                #endregion
                #region request svar kmh
                var svar_kmh = from kmh in provider.Specification_2s
                                    where (kmh.OrderArticleID == order_id)
                                        && kmh.StartDT <= CurDateTime
                                        && kmh.FinishDT > CurDateTime
                                        && kmh._Product_ID == prod._dictNomenID
                                        && kmh._dictS_TEID == new Guid("61931973-A5BD-40CD-92A6-FA802DE6CE6A")
                                    select kmh;
                if (svar_kmh.Count() == 0)
                {
                    svar_kmh = from kmh in provider.Specification_2s
                                    where kmh.OrderArticleID == null
                                        && kmh.StartDT <= svarDate
                                        && kmh.FinishDT > svarDate
                                        && kmh._Product_ID == prod._dictNomenID
                                    select kmh;
                }
                #endregion
                #region request techn kmh
                var techn_kmh = from kmh in provider.Specification_2s
                                    where (kmh.OrderArticleID == order_id)
                                        && kmh.StartDT <= CurDateTime
                                        && kmh.FinishDT > CurDateTime
                                        && kmh._Product_ID == prod._dictNomenID
                                    select kmh;
                if (techn_kmh.Count() == 0)
                {
                    techn_kmh = from kmh in provider.Specification_2s
                                    where kmh.OrderArticleID == null
                                        && kmh.StartDT <= technDate
                                        && kmh.FinishDT > technDate
                                        && kmh._Product_ID == prod._dictNomenID
                                        && kmh._dictS_TEID == new Guid("BCE12453-3AB9-4FCB-8FB3-4811A311B764")
                                    select kmh;
                }
                #endregion

                var actual_kmh = new List<Specification_2>();
                actual_kmh.AddRange(him_kmh);
                actual_kmh.AddRange(techn_kmh);
                actual_kmh.AddRange(svar_kmh);

                List<transfer_add> list = new List<transfer_add>();
                foreach (Specification_2 iter_kmh in actual_kmh)
                {
                    // пропускаем специальный материал с Guid = {00000000-0000-0000-0000-000000000000}
                    // которые обозначают пустые списки
                    if (iter_kmh._Material_ID == Guid.Empty) continue;

                    transfer_add add_material = new transfer_add()
                    {
                        s_id = iter_kmh._dictSID,
                        material = !iter_kmh._Material_ID.HasValue ? "" : iter_kmh.Material.superpole,
                        um_id = iter_kmh._dictUMID,
                        ste_id = iter_kmh._dictS_TEID,
                        material_id = iter_kmh._Material_ID,
                        no = iter_kmh.no
                    };

                    list.Add(add_material);
                }

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                return serializer.Serialize(list);
            }
        }
예제 #8
0
        public static string GetTechConsist(Guid prod_id, Guid order_id)
        {
            using (ConfigurationTreeProvider provider = new ConfigurationTreeProvider())
            {
                // главный продукт (чья дата берётся как основная в случае по приказу)
                Product product = null;
                using (ProductProvider productProvider = new ProductProvider())
                {
                    product = productProvider.GetProduct(prod_id);
                }

                // для стандартных продуктов всегда берётся карта актуальная на текущий момент
                // для приказного продукта
                // * если карточка приказная - на текущий момент
                // * если карточка стандартная - на момент создания продукта
                //   !! в новой редакции, берётся не дата создания продукта, а дата из
                //   колонки [TechnDates].[gen_date]
                DateTime currentDT = DateTime.Now;
                DateTime actualDT = Guid.Empty.Equals(order_id) ? currentDT : product.CreatedDate;

                // Получаем разузлованный состав
                List<transfer> list = new List<transfer>();
                DataSet data = provider.GetListWithKmh(prod_id, order_id, actualDT, currentDT);

                // добавляем самую верхнюю деталь
                /*transfer tran = new transfer();
                tran.prod_id = product.ID;
                tran.prod_pn1 = product._dictNomen.pn1;
                tran.prod_pn2 = product._dictNomen.pn2;

                #region attachKMH
                // получаем приказную актуальную карту
                Specification_1 order_kmh = null;
                try
                {
                    if (!Guid.Empty.Equals(order_id))
                    {
                        order_kmh = (from kmh in provider.Specification_1s
                                 where kmh.OrderArticleID == order_id
                                 && kmh._Product_ID == product._dictNomenID
                                 && kmh.StartDT <= currentDT
                                 && kmh.FinishDT > currentDT
                                 select kmh).Single();
                    }
                }
                catch {}

                // получеам стандартную актуальную карту
                Specification_1 stand_kmh = null;
                try
                {
                    stand_kmh = (from kmh in provider.Specification_1s
                                 where kmh.OrderArticleID == null
                                 && kmh._Product_ID == product._dictNomenID
                                 && kmh.StartDT <= actualDT
                                 && kmh.FinishDT > actualDT
                                 select kmh).Single();
                }
                catch {}

                if (!Guid.Empty.Equals(order_id) && order_kmh != null)
                {
                    FillKmh(order_kmh, tran, currentDT);
                }
                else if (stand_kmh != null)
                {
                    FillKmh(stand_kmh, tran, currentDT);
                }
                #endregion*/

                // получаем маршрут по применяемости
                /*try
                {
                    var route = (from r in provider.Specification_3s
                                 where r._Material_ID == product._dictNomenID
                                 && r._Product_ID == Guid.Empty
                                 && r.StartDT <= currentDT
                                 && r.FinishDT > currentDT
                                 select r).Single();
                    tran.route = route.Route;
                    tran.route_changed = true;
                } catch { }

                list.Add(tran);*/

                try
                {
                    #region getch result of query
                    foreach (DataRow row in data.Tables[0].Rows)
                    {
                        transfer tran = new transfer();

                        tran.unit_id = row.Field<Guid>("unitID");
                        tran.unit_pn1 = row.Field<string>("unitPn1");
                        tran.unit_pn2 = row.Field<string>("unitPn2");

                        tran.prod_id = row.Field<Guid>("prodID");
                        tran.prod_pn1 = row.Field<string>("prodPn1");
                        tran.prod_pn2 = row.Field<string>("prodPn2");

                        tran.level = row.Field<int>("Level");
                        tran.count = row.Field<decimal>("Quantity");
                        tran.group_exchange = row.Field<int?>("GroupToChange");
                        tran.number_exchange = row.Field<int?>("GroupNumber");

                        // дата добавления в состав должна быть только у приказных составов
                        tran.added_date = row.Field<DateTime?>("gen_date");

                        /*#region attachKMH
                        // получаем приказную актуальную карту
                        order_kmh = null;
                        try
                        {
                            if (!Guid.Empty.Equals(order_id))
                            {
                                order_kmh = (from kmh in provider.Specifications
                                         where kmh.tn == 1
                                         && kmh.OrderArticleID == order_id
                                         && kmh._Product_ID == row.Field<Guid>("prodNomenID")
                                         && kmh.StartDT < currentDT
                                         && kmh.FinishDT > currentDT
                                         select kmh).Single();
                            }
                        }
                        catch {}

                        // получеам стандартную актуальную карту
                        stand_kmh = null;
                        try
                        {
                            stand_kmh = (from kmh in provider.Specifications
                                         where kmh.tn == 1
                                         && kmh.OrderArticleID == null
                                         && kmh._Product_ID == row.Field<Guid>("prodNomenID")
                                         && kmh.StartDT < actualDT
                                         && kmh.FinishDT > actualDT
                                         select kmh).Single();
                        }
                        catch {}

                        if (!Guid.Empty.Equals(order_id) && order_kmh != null)
                        {
                            FillKmh(order_kmh, tran, currentDT);
                        }
                        else if (stand_kmh != null)
                        {
                            FillKmh(stand_kmh, tran, currentDT);
                        }
                        #endregion*/
                        FillKmhByRow(provider, row, tran, currentDT);

                        list.Add(tran);
                    }
                    #endregion
                }
                catch (Exception e)
                {
                    string tmpMessage = e.Message;
                }

                Dictionary<Guid,string> PVDs = provider._dictPVDs.AsEnumerable().ToDictionary(i => i.ID, i => i.pvdn);
                Dictionary<Guid, string> UMs = provider._dictUMs.AsEnumerable().ToDictionary(i => i.ID, i => i.umn1);
                Dictionary<Guid, string> SFs = provider._dictSFs.AsEnumerable().ToDictionary(i => i.ID, i => i.sfn);

                foreach (var item in list)
                {
                    try
                    {

                        item.pvd = item.pvd_id.HasValue ? PVDs[item.pvd_id.Value] : "";
                        item.um = item.um_id.HasValue ? UMs[item.um_id.Value] : "";
                        item.sf = item.sf_id.HasValue ? SFs[item.sf_id.Value] : "";
                    }
                    catch { };

                }

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                // some fix, because setting in web.config not always working as good
                serializer.MaxJsonLength = 50000000;
                return serializer.Serialize(list);
            }
        }
예제 #9
0
        /*
         * return weight of product multiply to it count -- if don't have child products
         * return summary weight of child products -- if have child products
         */
        protected decimal weightOfProduct(ProductProvider provider, Guid productId, int productCount, ref Statistic stat)
        {
            var confs = from m in provider.Configurations
                        where m.ProductOwnerID == productId
                        select new { m.GroupNumber, m._dictUMID, m.ProductID, m.Quantity };
            if (confs.Count() == 0)
            {
                // don't have child products
                Product product = provider.GetProduct(productId);
                decimal? weight =  product._dictNomen.pw;

                if (weight.HasValue)
                {
                    return weight.Value;
                }
                else
                {
                    stat.ingoreProducts += 1;
                    return 0;
                }

                /*
                var prop = from m in domain.ProductProperties
                           where m.PropertyID == new Guid("AC37F816-E4C1-4751-99ED-6180D7CCA142") // вес по приказу
                           && m.ProductID == productId
                           select new { m.Value };
                if (prop.Count() == 1)
                {
                    return Convert.ToDecimal(prop.First().Value) * productCount;
                }
                else
                {
                    // ignory because product don't have weight property
                    stat.ingoreProducts += 1;
                    return 0;
                }*/
            }
            else
            {
                // have child products
                decimal summaryWeight = 0;
                foreach (var conf in confs)
                {
                    if (conf.GroupNumber == 0 && conf._dictUMID == new Guid("68CD2019-85F6-4E52-AEFE-09CA5C2B64F3")) // штуки
                    {
                        summaryWeight += weightOfProduct(provider, conf.ProductID, Convert.ToInt32(conf.Quantity), ref stat);
                    }
                    else
                    {
                        // ignory because child product is order version
                        // or it measure not in pieces
                        stat.ingoreProducts += 1;
                    }

                }
                return summaryWeight;
            }
        }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                Guid cid = Guid.Empty;
                Guid eid = Guid.Empty;
                try
                {
                    cid = new Guid(Request["CID"]);
                    eid = new Guid(Request["ID"]);
                }
                catch (Exception)
                {
                    Edit.Visible = false;
                    Usage.Visible = false;
                    View.Visible = false;
                    Tree.Visible = false;
                    TreeEx.Visible = false;
                    EditObject.Visible = false;
                    NewObject.Visible = false;
                    ViewObject.Visible = false;
                    return;
                }

                if (cid != Guid.Empty) //dictionary entity
                {
                    if (cid == new Guid("316c6bc7-d883-44c8-aae0-602f49c73595"))
                    {
                        // добавляем пункт прикрепляемые файлы
                        string secretKey = MD5Hash(String.Format("{0}{1}{2}", AttachedFilesApplication, User.ID, new Guid(Request["ID"])));
                        string attachedUrl = @"javascript:CallAttachedFiles('{0}','{1}','{2}','{3}')";
                        AttachedFiles.NavigateUrl = string.Format(attachedUrl, AttachedFilesApplication, this.User.ID, new Guid(Request["ID"]), secretKey);
                    }
                    else
                    {
                        AttachedFiles.Visible = false;
                    }

                    NewObjectWithConfs.Visible = false;
                    Edit.Visible = false;
                    EditReadOnly.Visible = false;
                    Usage.Visible = false;
                    UsageWaves.Visible = false;
                    View.Visible = false;
                    Tree.Visible = false;
                    TreeEx.Visible = false;
                    TreeWithKmh.Visible = false;
                    EditKmh.Visible = false;
                    EditObject.NavigateUrl = string.Format("~/Editarea/EditDict.aspx?ID={0}&new=false&DictID={1}", Request["ID"], cid);
                    NewObject.NavigateUrl = string.Format("~/Editarea/EditDict.aspx?ID={0}&new=true&DictID={1}", Request["ID"], cid);
                    ViewObject.NavigateUrl = string.Format("~/Editarea/ViewDict.aspx?ID={0}&new=false&DictID={1}", Request["ID"], cid);

                    using (Aspect.Model.DictionaryDomain.DictionaryProvider provider = new Aspect.Model.DictionaryDomain.DictionaryProvider())
                    {
                        if (!provider.AllowEdit(this.Roles, cid))
                        {
                            EditObject.Visible = false;
                            NewObject.Visible = false;
                        }
                    }
                }
                else //product entity
                {
                    NewObject.Text = "Добавить новую версию";
                    NewObjectWithConfs.NavigateUrl = string.Format("{0}?ID={1}", NewObjectWithConfs.NavigateUrl, Request["ID"]);
                    Edit.NavigateUrl = string.Format("{0}?ID={1}", Edit.NavigateUrl, Request["ID"]);
                    EditReadOnly.NavigateUrl = string.Format("{0}?ID={1}&mode=view", EditReadOnly.NavigateUrl, Request["ID"]);
                    Usage.NavigateUrl = string.Format("{0}?ID={1}", Usage.NavigateUrl, Request["ID"]);
                    UsageWaves.NavigateUrl = string.Format("{0}?prodid={1}", UsageWaves.NavigateUrl, Request["ID"]);
                    View.NavigateUrl = string.Format("{0}?ID={1}", View.NavigateUrl, Request["ID"]);
                    Tree.NavigateUrl = string.Format("{0}?ID={1}", Tree.NavigateUrl, Request["ID"]);
                    TreeEx.NavigateUrl = string.Format("{0}?ID={1}", TreeEx.NavigateUrl, Request["ID"]);

                    EditObject.NavigateUrl = string.Format("{0}?ID={1}&new=false", EditObject.NavigateUrl, Request["ID"]);
                    NewObject.NavigateUrl = string.Format("{0}?ID={1}&new=true", NewObject.NavigateUrl, Request["ID"]);

                    ViewObject.NavigateUrl = string.Format("{0}?ID={1}&new=false", ViewObject.NavigateUrl, Request["ID"]);

                    using (Aspect.Model.ProductDomain.ProductProvider provider = new Aspect.Model.ProductDomain.ProductProvider())
                    {
                        if (!provider.AllowEdit(this.Roles, eid))
                        {
                            EditObject.Visible = false;
                            NewObject.Visible = false;
                            Edit.Visible = false;
                        }

                        // добавляем пункт прикрепляемые файлы
                        Product prod = provider.GetProduct(new Guid(Request["ID"]));
                        string secretKey = MD5Hash(String.Format("{0}{1}{2}", AttachedFilesApplication, User.ID, prod._dictNomenID));
                        string attachedUrl = @"javascript:CallAttachedFiles('{0}','{1}','{2}','{3}')";
                        AttachedFiles.NavigateUrl = string.Format(attachedUrl, AttachedFilesApplication, this.User.ID, prod._dictNomenID, secretKey);

                        // ищем продукт в приказных изделиях
                        if (!String.IsNullOrEmpty(Request.QueryString["order_id"]))
                        {
                            TreeWithKmh.NavigateUrl = string.Format("{0}?prodid={1}&orderid={2}", TreeWithKmh.NavigateUrl, Request["ID"], Request["order_id"]);
                        }
                        else
                        {
                            Product product = provider.GetProduct(eid);
                            if (!String.IsNullOrEmpty(product.OrderNumber) && !String.IsNullOrEmpty(product.OrderYear))
                            {
                                // приказное изделия
                                var orders = from order in provider.OrderArticles
                                             where order.year == product.OrderYear
                                             && order.cco == product.OrderNumber
                                             select order;
                                if (orders.Count() > 0)
                                {
                                    // есть приказ соотвествующий номеру и году
                                    TreeWithKmh.NavigateUrl = string.Format("{0}?prodid={1}&orderid={2}", TreeWithKmh.NavigateUrl, Request["ID"], orders.First().ID);
                                    EditKmh.NavigateUrl = string.Format("/Technology/EditorKmh.aspx?prodid={0}&orderid={1}", Request["ID"], orders.First().ID);
                                }
                                else
                                {
                                    // приказа нет, поэтому будем считать его стандартным
                                    TreeWithKmh.NavigateUrl = string.Format("{0}?prodid={1}", TreeWithKmh.NavigateUrl, Request["ID"]);
                                    EditKmh.NavigateUrl = string.Format("/Technology/EditorKmh.aspx?prodid={0}", Request["ID"]);
                                }
                            }
                            else
                            {
                                // не приказное изделие
                                TreeWithKmh.NavigateUrl = string.Format("{0}?prodid={1}", TreeWithKmh.NavigateUrl, Request["ID"]);
                                EditKmh.NavigateUrl = string.Format("/Technology/EditorKmh.aspx?prodid={0}", Request["ID"]);
                            }
                        }

                        if (provider.IsMainVersion(eid))
                        {
                            /*
                             * для основных версий запрещается редактирование
                             * характеристик и состава
                             */
                            EditObject.Visible = false;
                            Edit.Visible = false;
                        }
                        else
                        {
                            /*
                             * для НЕосновных версий запрещается создание
                             * новых версий и новых версий с составом
                             */
                            NewObject.Visible = false;
                            NewObjectWithConfs.Visible = false;
                        }

                        if (provider.isPrikazVersion(eid) || provider.isLessOfMainVersion(eid))
                        {
                            /*
                             * для приказных версий запрещается редактирование
                             * характеристик и состава
                             */
                            EditObject.Visible = false;
                            Edit.Visible = false;
                        }

                        if (provider.IsNotConfigurationable(eid))
                        {
                            /*
                             * для простых продуктов (материалы, прочие, ...)
                             * запрещены любые манипуляции с составом
                             */
                            NewObjectWithConfs.Visible = false;
                            Edit.Visible = false;
                            EditReadOnly.Visible = false;
                            View.Visible = false;
                            Tree.Visible = false;
                            TreeEx.Visible = false;
                        }

                        if (!TechnologyEnable)
                        {
                            TreeWithKmh.Visible = false;
                        }
                    }
                }

                // применяем разрешения для пунктов меню
                List<KeyValuePair<HyperLink, Guid>> menuList = new List<KeyValuePair<HyperLink,Guid>>();
                menuList.Add(new KeyValuePair<HyperLink,Guid>(EditObject, new Guid("8e227deb-6c24-4904-997a-0e9aeb768a3c")));
                menuList.Add(new KeyValuePair<HyperLink,Guid>(ViewObject, new Guid("8f6c3479-0905-4f05-a4cb-f06de253be73")));
                menuList.Add(new KeyValuePair<HyperLink,Guid>(NewObject, new Guid("20a57357-7f79-4af5-87e0-35192d16d736")));
                menuList.Add(new KeyValuePair<HyperLink,Guid>(AttachedFiles, new Guid("a96e10df-fb98-42a4-8c48-c8d5c40d1536")));
                menuList.Add(new KeyValuePair<HyperLink,Guid>(NewObjectWithConfs, new Guid("fe711646-62ce-4f34-b1e3-67e2376a5ff3")));
                menuList.Add(new KeyValuePair<HyperLink,Guid>(Edit, new Guid("71ea2f2b-a5ab-4cad-b1c1-d025fe92eb4e")));
                menuList.Add(new KeyValuePair<HyperLink,Guid>(EditReadOnly, new Guid("972431d2-cca3-46f1-bc79-b4f8250fb68f")));
                menuList.Add(new KeyValuePair<HyperLink,Guid>(Usage, new Guid("65e7bea5-4a86-4b02-bfcc-3ae0ae0192d8")));
                menuList.Add(new KeyValuePair<HyperLink, Guid>(UsageWaves, new Guid("F0370805-D740-4B0B-A9E6-786905F172F8")));
                menuList.Add(new KeyValuePair<HyperLink,Guid>(View, new Guid("079e49a6-0d19-42b6-a8fe-6b1237d84c78")));
                menuList.Add(new KeyValuePair<HyperLink,Guid>(Tree, new Guid("4a4f9ffe-1686-4f01-8c35-065cea788a54")));
                menuList.Add(new KeyValuePair<HyperLink,Guid>(TreeWithKmh, new Guid("98d79f99-6b09-4846-9af8-6bacb71b7bef")));

                using (ProductProvider provider = new ProductProvider())
                {
                    List<Guid> userRoles = (from role in provider.UserRoles
                                            where role.UserID == User.ID
                                            select role.RoleID).ToList();

                    var permisions = from perm in provider.RoleViewPermissions
                                     where perm.PermissionEntityID == new Guid("0097C313-2EAD-4E1A-B12C-BB31F110A367") // MenuActionItem
                                     && userRoles.Contains(perm.RoleID)
                                     select perm;

                    foreach (var menuItem in menuList)
                    {
                        if (permisions.Count(perm => perm.EntityID == menuItem.Value && perm.Read) > 0)
                        {
                            menuItem.Key.Enabled = true;
                        }
                        else
                        {
                            menuItem.Key.Enabled = false;
                            menuItem.Key.ForeColor = Color.LightGray;
                        }
                    }

                }

            }
            //Response.Write(Request["ID"]);
        }
예제 #11
0
        public static string GenerateForOrder(Guid order_id, Guid product_id, DateTime gen_date)
        {
            using (ConfigurationTreeProvider provider = new ConfigurationTreeProvider())
            {
                // получаем разузлованный состав для данной главной детали
                DataSet tree = provider.GetList(FormGridView.ConfigurationTree, product_id, UserID, new List<SearchExpression>());

                // удаляем все существующие даты для данного изделия и данного приказа
                var subprod_dictNomenIDs = new List<Guid>();
                foreach (DataRow row in tree.Tables[0].Rows)
                {
                    subprod_dictNomenIDs.Add((Guid)row["_dictNomenID"]);
                }
                using (ProductProvider pprovider = new ProductProvider())
                {
                    subprod_dictNomenIDs.Add(pprovider.GetProduct(product_id)._dictNomenID.Value);
                }

                var datesForDelete = provider.TechnDates.Where(
                    it => subprod_dictNomenIDs.Contains(it._dictNomenID)
                    && it.OrderArticleID == order_id);

                provider.TechnDates.DeleteAllOnSubmit(datesForDelete);
                provider.SubmitChanges();

                // создаём новые записи для данного приказа
                foreach (Guid subprod_dictNomenID in subprod_dictNomenIDs.Distinct())
                {
                    provider.TechnDates.InsertOnSubmit(new TechnDate()
                    {
                        OrderArticleID = order_id,
                        _dictNomenID = subprod_dictNomenID,
                        gen_date = gen_date
                    });
                }

                provider.SubmitChanges();
            }
            return new PostResult("ok", 0).ToString();
        }
예제 #12
0
        public static string SaveForProduct(Guid product_id, Guid order_id, transfer_techn_dates dates)
        {
            try
            {
                using (ProductProvider provider = new ProductProvider())
                {
                    var product = provider.GetProduct(product_id);
                    if (product == null)
                    {
                        return new PostResult("Certain product not found.", 404).ToString();
                    }

                    // select row with dates from DB
                    var unit_dates = provider.TechnReadinesses.SingleOrDefault(it
                        => it._dictNomenID == product._dictNomenID
                        && it.OrderArticleID == order_id);

                    // if row doesn't exists create new row
                    if (unit_dates == null)
                    {
                        unit_dates = new TechnReadiness()
                        {
                            _dictNomenID = product._dictNomenID.Value,
                            OrderArticleID = order_id
                        };
                        provider.TechnReadinesses.InsertOnSubmit(unit_dates);
                    }

                    // clear dates if needed and save dates to row
                    unit_dates.techn_date = dates.techn_date;
                    unit_dates.svar_date = dates.svar_date;
                    unit_dates.him_date = dates.him_date;

                    // if row contain all nulled fields delete it
                    if (unit_dates.techn_date == null &&
                        unit_dates.him_date == null &&
                        unit_dates.svar_date == null)
                    {
                        provider.TechnReadinesses.DeleteOnSubmit(unit_dates);
                    }

                    // save dates to DB
                    provider.SubmitChanges();
                }
                return new PostResult("Ok", 0).ToString();
            }
            catch (Exception e)
            {
                return new PostResult("Unknown exception: " + e.Message, -1).ToString();
            }
        }
예제 #13
0
        public static string GetForProduct(Guid order_id, Guid product_id)
        {
            using (ProductProvider provider = new ProductProvider())
            {
                var product = provider.GetProduct(product_id);
                if (product == null)
                {
                    return new PostResult("Certain product not found.", 404).ToString();
                }

                var date = provider.TechnReadinesses.SingleOrDefault(it =>
                    it.OrderArticleID == order_id
                    && it._dictNomenID == product._dictNomenID);

                if (date == null)
                {
                    return new PostResult("Not found certain row in table [dbo].[TechnDates].", 401).ToString();
                }

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                return serializer.Serialize(new transfer_techn_dates()
                {
                    order_id = order_id,
                    dictnomen_id = product._dictNomenID.Value,

                    svar_date = date.svar_date,
                    him_date = date.him_date,
                    techn_date = date.techn_date
                });
            }
        }
예제 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (ProductProvider provider = new ProductProvider())
            {

                List<Guid> lg = new List<Guid>();
                IOrderedEnumerable<Guid> lg_q;

                lg_q = null;
                  //     Dictionary<Guid, Guid> MultiBuffer= new Dictionary<Guid, Guid>();
                //    MultiBuffer=this.Session["MultiBuffer"];

                try
                {
                    if (provider != null)
                    {
                        if ((this.MultiBuffer.Count > 0))
                        {
                            //                            lg_q = this.MultiBuffer.Keys.ToList().OrderBy(x => x);
                            lg = this.MultiBuffer.Keys.ToList();
                        }
                        else return;
                    }

                }
                finally
                {
              //                  if (provider != null) provider.Dispose();
                }

                List<Product> lp = new List<Product>();
                IOrderedEnumerable<Product> lp_q;
                lp_q=null;
                UsageResponse response = new UsageResponse();
                foreach (Guid prodID in lg)
                {
                    if (provider.IsMainVersion(prodID))  // || provider.isPrikazVersion(prodID))
                    {
                        Product prod = provider.GetProduct(prodID);
                        lp.Add(prod);
                      };
                }
                if (lp.Count == 0)
                {

                    return;

                }
                lp_q = lp.OrderBy(x => x._dictNomen.superpole);

                foreach (Product prod in lp_q)
                {
                     UsageRow row = new UsageRow(prod.ID, prod._dictNomen.superpole, "1","1","1", //bvv120420
                        "1",
                        "", "","0");
                    response.rows.Add(row);
                }

                response.totalCount = response.rows.Count;
                //response.rows = response.rows.OrderBy(c => c.superpole);
                JavaScriptSerializer js = new JavaScriptSerializer();
                jsonResponse = js.Serialize(response);

                 /*

                  Guid uid = new Guid(Request["uid"]);

                //List<Aspect.Domain.Configuration> confs = provider.Configurations.Where(c => c.ProductID == uid).ToList(); //bvv120420

                /*
                                var s = from confs0 in provider.Configurations
                                        join pp in provider.ProductProperties on confs0.ProductOwnerID equals pp.ProductID
                                        where confs0.ProductID == uid && pp.PropertyID == new Guid("BBE170B0-28E4-4738-B365-1038B03F4552") && pp.Value == "1"
                                        select confs0;//bvv120420

                 *
                 *
                 *
                 *
                 *
                 * List<Aspect.Domain.Configuration> confs = s.ToList<Aspect.Domain.Configuration>(); //bvv120420

                 */

            /*
                var s = from confs0 in provider.Configurations
                        join pp in provider.ProductProperties on confs0.ProductOwnerID equals pp.ProductID
                        join p in provider.Products on confs0.ProductOwnerID equals p.ID
                        join n in provider._dictNomens on p._dictNomenID equals n.ID
                        where confs0.ProductID == uid && pp.PropertyID == new Guid("BBE170B0-28E4-4738-B365-1038B03F4552") && pp.Value == "1"
                        orderby n.superpole
                        select confs0;//bvv120420

                 List<Aspect.Domain.Configuration> confs = s.OrderBy(c=>c.Product1._dictNomen.superpole).ToList<Aspect.Domain.Configuration>(); //bvv120420

                List<Guid> ownerProdsId = confs.DistinctBy(c => c.ProductOwnerID).Select(c => c.ProductOwnerID).ToList();

                List<Product> ownerProds = provider.Products.Where(p => ownerProdsId.Contains(p.ID)).OrderBy(p=>p._dictNomen.superpole).ToList();//bvv120420

                UsageResponse response = new UsageResponse();
                foreach (Product prod in ownerProds)
                {
                    if (provider.IsMainVersion(prod.ID) || provider.isPrikazVersion(prod.ID))
                    {

                        var ff = from confs0 in provider.Configurations
                                where confs0.ProductID == uid && confs0.ProductOwnerID == prod.ID
                                select confs0.Quantity;//bvv120420

                        UsageRow row = new UsageRow(prod.ID, prod._dictNomen.superpole, ff.First().ToString(), ff.First().ToString(), prod.Version, //bvv120420
                            prod.MainVersion,
                            prod.OrderYear, prod.OrderNumber);
                        response.rows.Add(row);
                    };
                }

                response.totalCount = response.rows.Count;
                //response.rows = response.rows.OrderBy(c => c.superpole);
                JavaScriptSerializer js = new JavaScriptSerializer();
                jsonResponse = js.Serialize(response);
             */

              }
        }
예제 #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();
        }