Beispiel #1
0
 private void btnCreateValueAdd_Click(object sender, EventArgs e)
 {
     AttributeValueInfo info = new AttributeValueInfo();
     IList<AttributeValueInfo> list = new List<AttributeValueInfo>();
     int num = int.Parse(this.currentAttributeId.Value);
     info.AttributeId = num;
     if (!string.IsNullOrEmpty(this.txtValueStr.Text.Trim()))
     {
         string[] strArray = this.txtValueStr.Text.Trim().Split(new char[] { ',' });
         for (int i = 0; i < strArray.Length; i++)
         {
             if (strArray[i].Length > 100)
             {
                 break;
             }
             AttributeValueInfo item = new AttributeValueInfo();
             if (strArray[i].Length > 15)
             {
                 string str = string.Format("ShowMsg(\"{0}\", {1});", "属性值限制在15个字符以内", "false");
                 this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>");
                 return;
             }
             item.ValueStr = Globals.HtmlEncode(strArray[i]).Replace("+", "");
             item.AttributeId = num;
             list.Add(item);
         }
         foreach (AttributeValueInfo info3 in list)
         {
             ProductTypeHelper.AddAttributeValue(info3);
         }
         this.txtValueStr.Text = string.Empty;
         base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
     }
 }
 public bool UpdateAttributeValue(AttributeValueInfo attributeValue)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_AttributeValues SET  ValueStr=@ValueStr, ImageUrl=@ImageUrl WHERE ValueId=@valueId");
     this.database.AddInParameter(sqlStringCommand, "ValueStr", DbType.String, attributeValue.ValueStr);
     this.database.AddInParameter(sqlStringCommand, "ValueId", DbType.Int32, attributeValue.ValueId);
     this.database.AddInParameter(sqlStringCommand, "ImageUrl", DbType.String, attributeValue.ImageUrl);
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Beispiel #3
0
 public override bool AddAttributeValue(AttributeValueInfo attributeValue)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("DECLARE @DisplaySequence AS INT SELECT @DisplaySequence = (CASE WHEN MAX(DisplaySequence) IS NULL THEN 1 ELSE MAX(DisplaySequence) + 1 END) FROM Hishop_AttributeValues; INSERT INTO Hishop_AttributeValues(AttributeId, DisplaySequence, ValueStr, ImageUrl) VALUES(@AttributeId, @DisplaySequence, @ValueStr, @ImageUrl)");
     database.AddInParameter(sqlStringCommand, "AttributeId", DbType.Int32, attributeValue.AttributeId);
     database.AddInParameter(sqlStringCommand, "ValueStr", DbType.String, attributeValue.ValueStr);
     database.AddInParameter(sqlStringCommand, "ImageUrl", DbType.String, attributeValue.ImageUrl);
     return (database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
        /// <summary>
        /// 创建规格值
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCreateValue_Click(object sender, EventArgs e)
        {
            AttributeValueInfo attributeValue = new AttributeValueInfo();
            IList<AttributeValueInfo> list = new List<AttributeValueInfo>();
            int num = int.Parse(currentAttributeId.Value);
            attributeValue.AttributeId = num;
            if (!string.IsNullOrEmpty(txtValueStr.Text.Trim()))
            {
                string[] strArray = txtValueStr.Text.Trim().Split(new char[] { ',' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    if (strArray[i].Length > 100)
                    {
                        break;
                    }
                    AttributeValueInfo item = new AttributeValueInfo();
                    if (strArray[i].Length > 15)
                    {
                        string str = string.Format("ShowMsg(\"{0}\", {1});", "属性值限制在15个字符以内", "false");
                        Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>");
                        return;
                    }
                    item.ValueStr = Globals.HtmlEncode(strArray[i]);
                    item.AttributeId = num;
                    list.Add(item);
                }
                foreach (AttributeValueInfo info3 in list)
                {
                    ProductTypeHelper.AddAttributeValue(info3);
                }
                txtValueStr.Text = string.Empty;
                base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
            }
            if (fileUpload.HasFile)
            {
                try
                {
                    attributeValue.ImageUrl = ProductTypeHelper.UploadSKUImage(fileUpload.PostedFile);

                   // if (!string.IsNullOrEmpty(attributeValue.ValueStr))
                    //{
                        attributeValue.ValueStr = Globals.HtmlEncode(txtValueDec.Text);
                    ////}
                    ////else
                    ////{
                    ////    throw new Exception("测试抛出的错误:ValueStr为NULL!");
                    ////}
                }
                catch
                {
                }
                if (ProductTypeHelper.AddAttributeValue(attributeValue))
                {
                    txtValueStr.Text = string.Empty;
                    base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
                }
            }
        }
 public int AddAttributeValue(AttributeValueInfo attributeValue)
 {
     int num = 0;
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DECLARE @DisplaySequence AS INT SELECT @DisplaySequence = (CASE WHEN MAX(DisplaySequence) IS NULL THEN 1 ELSE MAX(DisplaySequence) + 1 END) FROM Hishop_AttributeValues; INSERT INTO Hishop_AttributeValues(AttributeId, DisplaySequence, ValueStr, ImageUrl) VALUES(@AttributeId, @DisplaySequence, @ValueStr, @ImageUrl);SELECT @@IDENTITY");
     this.database.AddInParameter(sqlStringCommand, "AttributeId", DbType.Int32, attributeValue.AttributeId);
     this.database.AddInParameter(sqlStringCommand, "ValueStr", DbType.String, attributeValue.ValueStr);
     this.database.AddInParameter(sqlStringCommand, "ImageUrl", DbType.String, attributeValue.ImageUrl);
     object obj2 = this.database.ExecuteScalar(sqlStringCommand);
     if (obj2 != null)
     {
         num = Convert.ToInt32(obj2.ToString());
     }
     return num;
 }
Beispiel #6
0
 public override IList<AttributeInfo> GetAttributeInfoByCategoryId(int categoryId)
 {
     IList<AttributeInfo> list = new List<AttributeInfo>();
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_AttributeValues WHERE AttributeId IN (SELECT AttributeId FROM Hishop_Attributes WHERE TypeId=(SELECT AssociatedProductType FROM distro_Categories WHERE CategoryId=@CategoryId) AND UsageMode <> 2) AND ValueId IN (SELECT ValueId FROM Hishop_ProductAttributes WHERE ProductId IN (SELECT ProductId FROM distro_Products WHERE DistributorUserId = @DistributorUserId)) ORDER BY DisplaySequence DESC; SELECT * FROM Hishop_Attributes WHERE TypeId=(SELECT AssociatedProductType FROM distro_Categories WHERE CategoryId=@CategoryId) AND UsageMode <> 2 AND AttributeId IN (SELECT AttributeId FROM Hishop_ProductAttributes WHERE ProductId IN (SELECT ProductId FROM distro_Products WHERE DistributorUserId = @DistributorUserId)) ORDER BY DisplaySequence DESC");
     this.database.AddInParameter(sqlStringCommand, "CategoryId", DbType.Int32, categoryId);
     this.database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.SiteSettings.UserId.Value);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         IList<AttributeValueInfo> list2 = new List<AttributeValueInfo>();
         while (reader.Read())
         {
             AttributeValueInfo item = new AttributeValueInfo();
             item.ValueId = (int) reader["ValueId"];
             item.AttributeId = (int) reader["AttributeId"];
             item.DisplaySequence = (int) reader["DisplaySequence"];
             item.ValueStr = (string) reader["ValueStr"];
             if (reader["ImageUrl"] != DBNull.Value)
             {
                 item.ImageUrl = (string) reader["ImageUrl"];
             }
             list2.Add(item);
         }
         if (!reader.NextResult())
         {
             return list;
         }
         while (reader.Read())
         {
             AttributeInfo info2 = new AttributeInfo();
             info2.AttributeId = (int) reader["AttributeId"];
             info2.AttributeName = (string) reader["AttributeName"];
             info2.DisplaySequence = (int) reader["DisplaySequence"];
             info2.TypeId = (int) reader["TypeId"];
             info2.UsageMode = (AttributeUseageMode) ((int) reader["UsageMode"]);
             info2.UseAttributeImage = (bool) reader["UseAttributeImage"];
             foreach (AttributeValueInfo info3 in list2)
             {
                 if (info2.AttributeId == info3.AttributeId)
                 {
                     info2.AttributeValues.Add(info3);
                 }
             }
             list.Add(info2);
         }
     }
     return list;
 }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     AttributeValueInfo attributeValue = new AttributeValueInfo();
     if ((this.txtValue.Text.Trim().Length > 15) || (this.txtValue.Text.Trim().Length == 0))
     {
         this.ShowMsg("属性值必须小于15个字符,不能为空", false);
     }
     else
     {
         attributeValue.ValueStr = this.txtValue.Text.Trim().Replace("+", "");
         attributeValue.AttributeId = this.attributeId;
         if (ProductTypeHelper.AddAttributeValue(attributeValue) > 0)
         {
             this.BindData();
             this.ShowMsg("添加成功", true);
         }
     }
 }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     AttributeValueInfo attributeValue = new AttributeValueInfo();
     if (((txtValue.Text.Trim().Length > 15) || (txtValue.Text.Trim().IndexOf(",") != -1)) || (txtValue.Text.Trim().Length == 0))
     {
         ShowMsg("属性值必须小于15个字符,不能为空,并且不能包含逗号", false);
     }
     else
     {
         attributeValue.ValueStr = txtValue.Text.Trim().Replace("+", "");
         attributeValue.AttributeId = attributeId;
         if (ProductTypeHelper.AddAttributeValue(attributeValue))
         {
             BindData();
             ShowMsg("添加成功", true);
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     int num;
     if ((!string.IsNullOrEmpty(base.Request["isCallback"]) && (base.Request["isCallback"] == "true")) && int.TryParse(base.Request["ValueId"], out num))
     {
         if (ProductTypeHelper.DeleteAttributeValue(num))
         {
             if (!string.IsNullOrEmpty(base.Request["ImageUrl"]))
             {
                 StoreHelper.DeleteImage(base.Request["ImageUrl"]);
                 base.Response.Clear();
                 base.Response.ContentType = "application/json";
                 base.Response.Write("{\"Status\":\"true\"}");
                 base.Response.End();
             }
             else
             {
                 base.Response.Clear();
                 base.Response.ContentType = "application/json";
                 base.Response.Write("{\"Status\":\"true\"}");
                 base.Response.End();
             }
         }
         else
         {
             base.Response.Clear();
             base.Response.ContentType = "application/json";
             base.Response.Write("{\"Status\":\"false\"}");
             base.Response.End();
         }
     }
     if (!string.IsNullOrEmpty(base.Request["isAjax"]) && (base.Request["isAjax"] == "true"))
     {
         string str = base.Request["Mode"].ToString();
         string str2 = "";
         string str3 = "false";
         string str6 = str;
         if (str6 != null)
         {
             int num2;
             if (!(str6 == "Add"))
             {
                 if (str6 == "AddSkuItemValue")
                 {
                     str2 = "参数缺少";
                     if (int.TryParse(base.Request["AttributeId"], out num2))
                     {
                         string str5 = "";
                         str2 = "规格值名不允许为空!";
                         if (!string.IsNullOrEmpty(base.Request["ValueName"].ToString()))
                         {
                             str5 = Globals.HtmlEncode(base.Request["ValueName"].ToString().Replace("+", "").Replace(",", ""));
                             str2 = "规格值名长度不允许超过15个字符";
                             if (str5.Length < 15)
                             {
                                 AttributeValueInfo attributeValue = new AttributeValueInfo {
                                     ValueStr = str5,
                                     AttributeId = num2
                                 };
                                 int num4 = 0;
                                 str2 = "添加规格值失败";
                                 num4 = ProductTypeHelper.AddAttributeValue(attributeValue);
                                 if (num4 > 0)
                                 {
                                     str2 = num4.ToString();
                                     str3 = "true";
                                 }
                             }
                         }
                     }
                     base.Response.Clear();
                     base.Response.ContentType = "application/json";
                     base.Response.Write("{\"Status\":\"" + str3 + "\",\"msg\":\"" + str2 + "\"}");
                     base.Response.End();
                 }
             }
             else
             {
                 num2 = 0;
                 str2 = "参数缺少";
                 if (int.TryParse(base.Request["AttributeId"], out num2))
                 {
                     string str4 = "";
                     str2 = "属性名称不允许为空!";
                     if (!string.IsNullOrEmpty(base.Request["ValueName"].ToString()))
                     {
                         str4 = Globals.HtmlEncode(base.Request["ValueName"].ToString());
                         AttributeValueInfo info = new AttributeValueInfo {
                             ValueStr = str4,
                             AttributeId = num2
                         };
                         int num3 = 0;
                         str2 = "添加属性值失败";
                         num3 = ProductTypeHelper.AddAttributeValue(info);
                         if (num3 > 0)
                         {
                             str2 = num3.ToString();
                             str3 = "true";
                         }
                     }
                 }
                 base.Response.Clear();
                 base.Response.ContentType = "application/json";
                 base.Response.Write("{\"Status\":\"" + str3 + "\",\"msg\":\"" + str2 + "\"}");
                 base.Response.End();
             }
         }
     }
     this.btnFilish.Click += new EventHandler(this.btnFilish_Click);
 }
Beispiel #10
0
 public IList<AttributeInfo> GetAttributes(int typeId)
 {
     IList<AttributeInfo> list = new List<AttributeInfo>();
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_Attributes WHERE TypeId = @TypeId ORDER BY DisplaySequence DESC SELECT * FROM Hishop_AttributeValues WHERE AttributeId IN (SELECT AttributeId FROM Hishop_Attributes WHERE TypeId = @TypeId) ORDER BY DisplaySequence DESC");
     this.database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, typeId);
     using (DataSet set = this.database.ExecuteDataSet(sqlStringCommand))
     {
         foreach (DataRow row in set.Tables[0].Rows)
         {
             AttributeInfo item = new AttributeInfo {
                 AttributeId = (int) row["AttributeId"],
                 AttributeName = (string) row["AttributeName"],
                 DisplaySequence = (int) row["DisplaySequence"],
                 TypeId = (int) row["TypeId"],
                 UsageMode = (AttributeUseageMode) ((int) row["UsageMode"]),
                 UseAttributeImage = (bool) row["UseAttributeImage"]
             };
             if (set.Tables[1].Rows.Count > 0)
             {
                 DataRow[] rowArray = set.Tables[1].Select("AttributeId=" + item.AttributeId.ToString());
                 foreach (DataRow row2 in rowArray)
                 {
                     AttributeValueInfo info2 = new AttributeValueInfo {
                         ValueId = (int) row2["ValueId"],
                         AttributeId = item.AttributeId,
                         ValueStr = (string) row2["ValueStr"]
                     };
                     item.AttributeValues.Add(info2);
                 }
             }
             list.Add(item);
         }
     }
     return list;
 }
Beispiel #11
0
 public IList<AttributeInfo> GetAttributes(int typeId, AttributeUseageMode attributeUseageMode)
 {
     string str;
     IList<AttributeInfo> list = new List<AttributeInfo>();
     if (attributeUseageMode == AttributeUseageMode.Choose)
     {
         str = "UsageMode = 2";
     }
     else
     {
         str = "UsageMode <> 2";
     }
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_Attributes WHERE TypeId = @TypeId AND " + str + " ORDER BY DisplaySequence Desc SELECT * FROM Hishop_AttributeValues WHERE AttributeId IN (SELECT AttributeId FROM Hishop_Attributes WHERE TypeId = @TypeId AND  " + str + " ) ORDER BY DisplaySequence Desc");
     this.database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, typeId);
     using (DataSet set = this.database.ExecuteDataSet(sqlStringCommand))
     {
         foreach (DataRow row in set.Tables[0].Rows)
         {
             AttributeInfo item = new AttributeInfo {
                 AttributeId = (int) row["AttributeId"],
                 AttributeName = (string) row["AttributeName"],
                 DisplaySequence = (int) row["DisplaySequence"],
                 TypeId = (int) row["TypeId"],
                 UsageMode = (AttributeUseageMode) ((int) row["UsageMode"]),
                 UseAttributeImage = (bool) row["UseAttributeImage"]
             };
             if (set.Tables[1].Rows.Count > 0)
             {
                 DataRow[] rowArray = set.Tables[1].Select("AttributeId=" + item.AttributeId.ToString());
                 foreach (DataRow row2 in rowArray)
                 {
                     AttributeValueInfo info2 = new AttributeValueInfo {
                         ValueId = (int) row2["ValueId"],
                         AttributeId = item.AttributeId
                     };
                     if (row2["ImageUrl"] != DBNull.Value)
                     {
                         info2.ImageUrl = (string) row2["ImageUrl"];
                     }
                     info2.ValueStr = (string) row2["ValueStr"];
                     item.AttributeValues.Add(info2);
                 }
             }
             list.Add(item);
         }
     }
     return list;
 }
Beispiel #12
0
 public static AttributeValueInfo PopulateAttributeValue(IDataReader reader)
 {
     if (reader == null)
     {
         return null;
     }
     AttributeValueInfo info = new AttributeValueInfo();
     info.ValueId = (int) reader["ValueId"];
     info.AttributeId = (int) reader["AttributeId"];
     info.ValueStr = (string) reader["ValueStr"];
     return info;
 }
Beispiel #13
0
 public abstract bool AddAttributeValue(AttributeValueInfo attributeValue);
 public static int GetSpecificationValueId(int attributeId, string valueStr)
 {
     int specificationValueId = new AttributeValueDao().GetSpecificationValueId(attributeId, valueStr);
     if (specificationValueId > 0)
     {
         return specificationValueId;
     }
     AttributeValueInfo attributeValue = new AttributeValueInfo {
         AttributeId = attributeId,
         ValueStr = valueStr
     };
     return new AttributeValueDao().AddAttributeValue(attributeValue);
 }
Beispiel #15
0
 public static bool AddAttributeValue(AttributeValueInfo attributeValue)
 {
     return ProductProvider.Instance().AddAttributeValue(attributeValue);
 }
Beispiel #16
0
 public static bool UpdateSku(AttributeValueInfo attributeValue)
 {
     return ProductProvider.Instance().UpdateSku(attributeValue);
 }
 void RenderButton(HtmlTextWriter writer)
 {
     IList<AttributeInfo> attributeInfoByCategoryId = new List<AttributeInfo>();
     attributeInfoByCategoryId = ProductBrowser.GetAttributeInfoByCategoryId(this.CategoryId);
     if (attributeInfoByCategoryId.Count > 0)
     {
         for (int i = 0; (i < this.MaxNum) && (i < attributeInfoByCategoryId.Count); i++)
         {
             WebControl control = new WebControl(HtmlTextWriterTag.Label);
             control.Controls.Add(new LiteralControl("<li>"));
             control.RenderControl(writer);
             WebControl control2 = new WebControl(HtmlTextWriterTag.Label);
             control2.Controls.Add(new LiteralControl("<span>" + attributeInfoByCategoryId[i].AttributeName + ":</span>"));
             control2.Attributes.Add("class", this.NameCss);
             control2.RenderControl(writer);
             WebControl control3 = new WebControl(HtmlTextWriterTag.A);
             control3.Controls.Add(new LiteralControl("全部"));
             if (!this.LinkSelf)
             {
                 control3.Attributes.Add("target", "_blank");
             }
             string str = "";
             if (!string.IsNullOrEmpty(this.ValueStr))
             {
                 string[] strArray = this.ValueStr.Split(new char[] { '-' });
                 if (strArray.Length >= 1)
                 {
                     for (int j = 0; j < strArray.Length; j++)
                     {
                         string[] strArray2 = strArray[j].Split(new char[] { '_' });
                         if ((strArray2.Length > 0) && (strArray2[0].IndexOf(attributeInfoByCategoryId[i].AttributeId.ToString()) != -1))
                         {
                             strArray2[1] = "0";
                             strArray[j] = strArray2[0] + "_" + strArray2[1];
                         }
                         if (string.IsNullOrEmpty(str))
                         {
                             str = str + strArray[j];
                         }
                         else
                         {
                             str = str + "-" + strArray[j];
                         }
                     }
                     if (str.IndexOf(attributeInfoByCategoryId[i].AttributeId.ToString()) == -1)
                     {
                         object obj2 = str;
                         str = string.Concat(new object[] { obj2, "-", attributeInfoByCategoryId[i].AttributeId, "_0" });
                     }
                 }
             }
             else
             {
                 str = attributeInfoByCategoryId[i].AttributeId + "_0";
             }
             if (string.IsNullOrEmpty(this.Page.Request.QueryString["valueStr"]))
             {
                 control3.Attributes.Add("class", this.AllCss);
             }
             else
             {
                 string str2 = this.Page.Request.QueryString["valueStr"];
                 if (str2 == str)
                 {
                     control3.Attributes.Add("class", this.AllCss);
                 }
             }
             control3.Attributes.Add("href", this.CreateUrl(str));
             control3.RenderControl(writer);
             foreach (AttributeValueInfo info in attributeInfoByCategoryId[i].AttributeValues)
             {
                 WebControl control4 = new WebControl(HtmlTextWriterTag.A);
                 control4.Controls.Add(new LiteralControl(info.ValueStr));
                 string str3 = "";
                 if (!string.IsNullOrEmpty(this.ValueStr))
                 {
                     string[] strArray3 = this.ValueStr.Split(new char[] { '-' });
                     if (strArray3.Length >= 1)
                     {
                         for (int k = 0; k < strArray3.Length; k++)
                         {
                             string[] strArray4 = strArray3[k].Split(new char[] { '_' });
                             if ((strArray4.Length > 0) && (strArray4[0].IndexOf(attributeInfoByCategoryId[i].AttributeId.ToString()) != -1))
                             {
                                 strArray4[1] = info.ValueId.ToString();
                                 strArray3[k] = strArray4[0] + "_" + strArray4[1];
                             }
                             if (string.IsNullOrEmpty(str3))
                             {
                                 str3 = str3 + strArray3[k];
                             }
                             else
                             {
                                 str3 = str3 + "-" + strArray3[k];
                             }
                         }
                         if (str3.IndexOf(attributeInfoByCategoryId[i].AttributeId.ToString()) == -1)
                         {
                             object obj3 = str3;
                             str3 = string.Concat(new object[] { obj3, "-", info.AttributeId, "_", info.ValueId });
                         }
                     }
                 }
                 else
                 {
                     str3 = info.AttributeId + "_" + info.ValueId;
                 }
                 bool flag = false;
                 if (!string.IsNullOrEmpty(this.Page.Request.QueryString["valueStr"]))
                 {
                     IList<AttributeValueInfo> list2 = new List<AttributeValueInfo>();
                     string str4 = Globals.UrlDecode(this.Page.Request.QueryString["valueStr"]);
                     string[] strArray5 = str4.Split(new char[] { '-' });
                     if (!string.IsNullOrEmpty(str4))
                     {
                         for (int m = 0; m < strArray5.Length; m++)
                         {
                             string[] strArray6 = strArray5[m].Split(new char[] { '_' });
                             if (((strArray6.Length > 0) && !string.IsNullOrEmpty(strArray6[1])) && (strArray6[1] != "0"))
                             {
                                 AttributeValueInfo item = new AttributeValueInfo();
                                 item.AttributeId = Convert.ToInt32(strArray6[0]);
                                 item.ValueId = Convert.ToInt32(strArray6[1]);
                                 if (info.ValueId == Convert.ToInt32(strArray6[1]))
                                 {
                                     control4.Attributes.Add("class", this.SelectCss);
                                     flag = true;
                                 }
                                 list2.Add(item);
                             }
                         }
                     }
                 }
                 if (!flag)
                 {
                     control4.Attributes.Add("href", this.CreateUrl(str3));
                 }
                 if (!this.LinkSelf)
                 {
                     control4.Attributes.Add("target", "_blank");
                 }
                 control4.RenderControl(writer);
             }
             WebControl control5 = new WebControl(HtmlTextWriterTag.Label);
             control5.Controls.Add(new LiteralControl("</li>"));
             control5.RenderControl(writer);
         }
     }
 }
Beispiel #18
0
 public abstract bool UpdateSku(AttributeValueInfo attributeValue);
 protected ProductBrowseQuery GetProductBrowseQuery()
 {
     int num2;
     ProductBrowseQuery entity = new ProductBrowseQuery();
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["categoryId"]))
     {
         int result = 0;
         if (int.TryParse(this.Page.Request.QueryString["categoryId"], out result))
         {
             entity.CategoryId = new int?(result);
         }
     }
     if (int.TryParse(this.Page.Request.QueryString["brand"], out num2))
     {
         entity.BrandId = new int?(num2);
     }
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["valueStr"]))
     {
         IList<AttributeValueInfo> list = new List<AttributeValueInfo>();
         string str = Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["valueStr"]));
         string[] strArray = str.Split(new char[] { '-' });
         if (!string.IsNullOrEmpty(str))
         {
             for (int i = 0; i < strArray.Length; i++)
             {
                 string[] strArray2 = strArray[i].Split(new char[] { '_' });
                 if (((strArray2.Length > 0) && !string.IsNullOrEmpty(strArray2[1])) && (strArray2[1] != "0"))
                 {
                     AttributeValueInfo item = new AttributeValueInfo();
                     item.AttributeId = Convert.ToInt32(strArray2[0]);
                     item.ValueId = Convert.ToInt32(strArray2[1]);
                     list.Add(item);
                 }
             }
         }
         entity.AttributeValues = list;
     }
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["isPrecise"]))
     {
         entity.IsPrecise = bool.Parse(Globals.UrlDecode(this.Page.Request.QueryString["isPrecise"]));
     }
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["keywords"]))
     {
         entity.Keywords = Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["keywords"]));
     }
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["minSalePrice"]))
     {
         decimal num4 = 0M;
         if (decimal.TryParse(Globals.UrlDecode(this.Page.Request.QueryString["minSalePrice"]), out num4))
         {
             entity.MinSalePrice = new decimal?(num4);
         }
     }
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["maxSalePrice"]))
     {
         decimal num5 = 0M;
         if (decimal.TryParse(Globals.UrlDecode(this.Page.Request.QueryString["maxSalePrice"]), out num5))
         {
             entity.MaxSalePrice = new decimal?(num5);
         }
     }
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productCode"]))
     {
         entity.ProductCode = Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["productCode"]));
     }
     entity.PageIndex = this.pager.PageIndex;
     entity.PageSize = this.rptProducts.PageSize;
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["sortOrderBy"]))
     {
         entity.SortBy = Globals.HtmlEncode(this.Page.Request.QueryString["sortOrderBy"]);
     }
     else
     {
         entity.SortBy = "DisplaySequence";
     }
     if (!string.IsNullOrEmpty(this.Page.Request.QueryString["sortOrder"]))
     {
         entity.SortOrder = (SortAction) Enum.Parse(typeof(SortAction), Globals.HtmlEncode(this.Page.Request.QueryString["sortOrder"]));
     }
     else
     {
         entity.SortOrder = SortAction.Desc;
     }
     Globals.EntityCoding(entity, true);
     return entity;
 }
 public static bool UpdateAttributeValue(AttributeValueInfo attributeValue)
 {
     return new AttributeValueDao().UpdateAttributeValue(attributeValue);
 }
Beispiel #21
0
 public override AttributeValueInfo GetAttributeValueInfo(int valueId)
 {
     AttributeValueInfo info = new AttributeValueInfo();
     DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM Hishop_AttributeValues WHERE ValueId=@ValueId");
     database.AddInParameter(sqlStringCommand, "ValueId", DbType.Int32, valueId);
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulateAttributeValue(reader);
             info.ImageUrl = reader["ImageUrl"].ToString();
             info.DisplaySequence = (int)reader["DisplaySequence"];
         }
     }
     return info;
 }
Beispiel #22
0
 public override AttributeInfo GetAttribute(int attributeId)
 {
     AttributeInfo info = new AttributeInfo();
     DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM Hishop_AttributeValues WHERE AttributeId = @AttributeId ORDER BY DisplaySequence DESC; SELECT * FROM Hishop_Attributes WHERE AttributeId = @AttributeId;");
     database.AddInParameter(sqlStringCommand, "AttributeId", DbType.Int32, attributeId);
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         IList<AttributeValueInfo> list = new List<AttributeValueInfo>();
         while (reader.Read())
         {
             AttributeValueInfo item = new AttributeValueInfo();
             item.ValueId = (int)reader["ValueId"];
             item.AttributeId = (int)reader["AttributeId"];
             item.DisplaySequence = (int)reader["DisplaySequence"];
             item.ValueStr = (string)reader["ValueStr"];
             if (reader["ImageUrl"] != DBNull.Value)
             {
                 item.ImageUrl = (string)reader["ImageUrl"];
             }
             list.Add(item);
         }
         if (!reader.NextResult())
         {
             return info;
         }
         if (reader.Read())
         {
             info.AttributeId = (int)reader["AttributeId"];
             info.AttributeName = (string)reader["AttributeName"];
             info.DisplaySequence = (int)reader["DisplaySequence"];
             info.TypeId = (int)reader["TypeId"];
             info.UsageMode = (AttributeUseageMode)((int)reader["UsageMode"]);
             info.UseAttributeImage = (bool)reader["UseAttributeImage"];
             info.AttributeValues = list;
         }
     }
     return info;
 }
 public static int AddAttributeValue(AttributeValueInfo attributeValue)
 {
     return new AttributeValueDao().AddAttributeValue(attributeValue);
 }
Beispiel #24
0
 protected void btnCreateValue_Click(object sender, EventArgs e)
 {
     AttributeValueInfo attributeValue = new AttributeValueInfo();
     IList<AttributeValueInfo> list = new List<AttributeValueInfo>();
     int num = int.Parse(this.currentAttributeId.Value);
     attributeValue.AttributeId = num;
     if (!(this.Page.Request.QueryString["action"].ToString().Trim() == "add"))
     {
         this.valueId = int.Parse(this.Page.Request.QueryString["valueId"]);
         attributeValue = ProductTypeHelper.GetAttributeValueInfo(this.valueId);
         if (ProductTypeHelper.GetAttribute(attributeValue.AttributeId).UseAttributeImage)
         {
             if (!string.IsNullOrEmpty(this.txtValueDec.Text))
             {
                 attributeValue.ValueStr = Globals.HtmlEncode(this.txtValueDec.Text);
             }
         }
         else if (!string.IsNullOrEmpty(this.txtValueStr.Text))
         {
             attributeValue.ValueStr = Globals.HtmlEncode(this.txtValueStr.Text);
         }
         if (this.fileUpload.HasFile)
         {
             try
             {
                 StoreHelper.DeleteImage(attributeValue.ImageUrl);
                 attributeValue.ImageUrl = ProductTypeHelper.UploadSKUImage(this.fileUpload.PostedFile);
             }
             catch
             {
             }
         }
         if (ProductTypeHelper.UpdateAttributeValue(attributeValue))
         {
             this.CloseWindow();
         }
     }
     else
     {
         if (!string.IsNullOrEmpty(this.txtValueStr.Text.Trim()))
         {
             string[] strArray = this.txtValueStr.Text.Trim().Split(new char[] { ',' });
             for (int i = 0; i < strArray.Length; i++)
             {
                 if (strArray[i].Trim().Length > 100)
                 {
                     break;
                 }
                 AttributeValueInfo item = new AttributeValueInfo();
                 if (strArray[i].Trim().Length > 15)
                 {
                     this.ShowMsg("属性值限制在15个字符以内", false);
                     return;
                 }
                 item.ValueStr = Globals.HtmlEncode(strArray[i].Trim());
                 item.AttributeId = num;
                 list.Add(item);
             }
             foreach (AttributeValueInfo info3 in list)
             {
                 ProductTypeHelper.AddAttributeValue(info3);
             }
             this.CloseWindow();
         }
         if (this.fileUpload.HasFile)
         {
             try
             {
                 attributeValue.ImageUrl = ProductTypeHelper.UploadSKUImage(this.fileUpload.PostedFile);
                 attributeValue.ValueStr = Globals.HtmlEncode(this.txtValueDec.Text);
             }
             catch
             {
             }
             if (ProductTypeHelper.AddAttributeValue(attributeValue) > 0)
             {
                 this.CloseWindow();
             }
         }
         else
         {
             this.ShowMsg("属性值限制在15个字符以内", false);
         }
     }
 }
Beispiel #25
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     if (this.txtName.Text.Trim().Length > 15)
     {
         string str = string.Format("ShowMsg(\"{0}\", {1});", "属性名称限制在15个字符以内", "false");
         this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>");
     }
     else
     {
         AttributeInfo info3 = new AttributeInfo();
         info3.TypeId = this.typeId;
         info3.AttributeName = Globals.HtmlEncode(this.txtName.Text.Trim());
         AttributeInfo target = info3;
         if (this.chkMulti.Checked)
         {
             target.UsageMode = AttributeUseageMode.MultiView;
         }
         else
         {
             target.UsageMode = AttributeUseageMode.View;
         }
         if (!string.IsNullOrEmpty(this.txtValues.Text.Trim()))
         {
             string[] strArray = this.txtValues.Text.Trim().Split(new char[] { ',' });
             for (int i = 0; i < strArray.Length; i++)
             {
                 if (strArray[i].Length > 100)
                 {
                     break;
                 }
                 AttributeValueInfo item = new AttributeValueInfo();
                 if (strArray[i].Length > 15)
                 {
                     string str2 = string.Format("ShowMsg(\"{0}\", {1});", "属性值限制在15个字符以内", "false");
                     this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str2 + "},300);</script>");
                     return;
                 }
                 item.ValueStr = Globals.HtmlEncode(strArray[i]);
                 target.AttributeValues.Add(item);
             }
         }
         ValidationResults results = Hishop.Components.Validation.Validation.Validate<AttributeInfo>(target, new string[] { "ValAttribute" });
         string str3 = string.Empty;
         if (!results.IsValid)
         {
             foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
             {
                 str3 = str3 + Formatter.FormatErrorMessage(result.Message);
             }
         }
         else if (ProductTypeHelper.AddAttribute(target))
         {
             this.txtName.Text = string.Empty;
             this.txtValues.Text = string.Empty;
             base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
         }
     }
 }