protected void Page_Load(object sender, EventArgs e) { using (ProductProvider provider = new ProductProvider()) { 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,"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); } }
protected void Page_Load(object sender, EventArgs e) { using (ProductProvider provider = new ProductProvider()) { Guid uid = new Guid(Request["uid"]); List<Aspect.Domain.Configuration> confs = provider.Configurations.Where(c => c.ProductID == uid).ToList(); List<Guid> ownerProdsId = confs.DistinctBy(c => c.ProductOwnerID).Select(c => c.ProductOwnerID).ToList(); List<Product> ownerProds = provider.Products.Where(p => ownerProdsId.Contains(p.ID)).ToList(); UsageResponse response = new UsageResponse(); foreach (Product prod in ownerProds) { if (provider.IsMainVersion(prod.ID) || provider.isPrikazVersion(prod.ID)) { UsageRow row = new UsageRow(prod.ID, prod._dictNomen.superpole, prod.Version, prod.MainVersion, prod.OrderYear, prod.OrderNumber); response.rows.Add(row); }; } response.totalCount = response.rows.Count; JavaScriptSerializer js = new JavaScriptSerializer(); jsonResponse = js.Serialize(response); } }
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"]); }
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); */ } }
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>()); } }
protected void Page_Load(object sender, EventArgs e) { if (IsViewMode) { ModeLabel.Text = "Просмотр"; AddFromBuffer.Visible = false; Save.Visible = false; Cancel.Visible = false; MadeBasicVersion.Visible = false; ReasonChanges.Visible = false; ReasonChangesLavel.Visible = false; } else { ModeLabel.Text = "Редактирование"; } if (!Page.IsPostBack) { // только при открытии спецификации на редактирование if (!IsViewMode) { using (ProductProvider provider = new ProductProvider()) { // для основных версий продукта создаём новую версию и // перенаправляем туда пользователя if (provider.IsMainVersion(ProductID)) { Guid newProductID = provider.CreateNewVersionOfProduct(ProductID, User.ID); Response.Redirect(String.Format("/Configuration/Edit.aspx?ID={0}", newProductID)); } } } this.PopupIframeInitializationString(ShowBuffer, "Буфер", "../Popup/Buffer.aspx", 700, 500); this.PopupIframeInitializationString(SummaryWeight, "Суммарный вес разузлованного состава", string.Format("../Popup/SummaryWeight.aspx?pid='+selectedProductID+'", hiddenSelectedProducts.Value == null ? "" : hiddenSelectedProducts.Value.ToString()), 700, 500); //this.BindGridColumns(); this.BindGridColumns2(); this.BindData(new Dictionary<Guid, Guid>()); } this.Title = HeaderLiteral.Text; }