Example #1
0
 public Maticsoft.Model.Shop.Products.CategoryInfo DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Shop.Products.CategoryInfo info = new Maticsoft.Model.Shop.Products.CategoryInfo();
     if (row != null)
     {
         if ((row["CategoryId"] != null) && (row["CategoryId"].ToString() != ""))
         {
             info.CategoryId = int.Parse(row["CategoryId"].ToString());
         }
         if ((row["DisplaySequence"] != null) && (row["DisplaySequence"].ToString() != ""))
         {
             info.DisplaySequence = int.Parse(row["DisplaySequence"].ToString());
         }
         if (row["Name"] != null)
         {
             info.Name = row["Name"].ToString();
         }
         if (row["Meta_Title"] != null)
         {
             info.Meta_Title = row["Meta_Title"].ToString();
         }
         if (row["Meta_Description"] != null)
         {
             info.Meta_Description = row["Meta_Description"].ToString();
         }
         if (row["Meta_Keywords"] != null)
         {
             info.Meta_Keywords = row["Meta_Keywords"].ToString();
         }
         if (row["Description"] != null)
         {
             info.Description = row["Description"].ToString();
         }
         if ((row["ParentCategoryId"] != null) && (row["ParentCategoryId"].ToString() != ""))
         {
             info.ParentCategoryId = int.Parse(row["ParentCategoryId"].ToString());
         }
         if ((row["Depth"] != null) && (row["Depth"].ToString() != ""))
         {
             info.Depth = int.Parse(row["Depth"].ToString());
         }
         if (row["Path"] != null)
         {
             info.Path = row["Path"].ToString();
         }
         if (row["RewriteName"] != null)
         {
             info.RewriteName = row["RewriteName"].ToString();
         }
         if (row["SKUPrefix"] != null)
         {
             info.SKUPrefix = row["SKUPrefix"].ToString();
         }
         if ((row["AssociatedProductType"] != null) && (row["AssociatedProductType"].ToString() != ""))
         {
             info.AssociatedProductType = new int?(int.Parse(row["AssociatedProductType"].ToString()));
         }
         if (row["ImageUrl"] != null)
         {
             info.ImageUrl = row["ImageUrl"].ToString();
         }
         if (row["Notes1"] != null)
         {
             info.Notes1 = row["Notes1"].ToString();
         }
         if (row["Notes2"] != null)
         {
             info.Notes2 = row["Notes2"].ToString();
         }
         if (row["Notes3"] != null)
         {
             info.Notes3 = row["Notes3"].ToString();
         }
         if (row["Notes4"] != null)
         {
             info.Notes4 = row["Notes4"].ToString();
         }
         if (row["Notes5"] != null)
         {
             info.Notes5 = row["Notes5"].ToString();
         }
         if (row["Theme"] != null)
         {
             info.Theme = row["Theme"].ToString();
         }
         if ((row["HasChildren"] != null) && (row["HasChildren"].ToString() != ""))
         {
             if ((row["HasChildren"].ToString() == "1") || (row["HasChildren"].ToString().ToLower() == "true"))
             {
                 info.HasChildren = true;
             }
             else
             {
                 info.HasChildren = false;
             }
         }
         if (row["SeoUrl"] != null)
         {
             info.SeoUrl = row["SeoUrl"].ToString();
         }
         if (row["SeoImageAlt"] != null)
         {
             info.SeoImageAlt = row["SeoImageAlt"].ToString();
         }
         if (row["SeoImageTitle"] != null)
         {
             info.SeoImageTitle = row["SeoImageTitle"].ToString();
         }
     }
     return info;
 }
Example #2
0
 public List<Maticsoft.Model.Shop.Products.CategoryInfo> NameTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Shop.Products.CategoryInfo> list = new List<Maticsoft.Model.Shop.Products.CategoryInfo>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Shop.Products.CategoryInfo item = new Maticsoft.Model.Shop.Products.CategoryInfo();
             if ((dt.Rows[i]["Name"] != null) && (dt.Rows[i]["Name"].ToString() != ""))
             {
                 item.Name = dt.Rows[i]["Name"].ToString();
             }
             list.Add(item);
         }
     }
     return list;
 }
Example #3
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     this.btnCancle.Enabled = false;
     this.btnSave.Enabled = false;
     if (string.IsNullOrWhiteSpace(this.txtName.Text.Trim()))
     {
         this.btnCancle.Enabled = true;
         this.btnSave.Enabled = true;
         MessageBox.ShowFailTip(this, "分类名称不能为空,在1至60个字符之间");
     }
     else
     {
         this.Hidden_SelectName.Value = this.txtCategoryText.Text;
         Maticsoft.Model.Shop.Products.CategoryInfo model = new Maticsoft.Model.Shop.Products.CategoryInfo {
             Name = this.txtName.Text,
             Meta_Description = this.txtMeta_Description.Text,
             Meta_Keywords = this.txtMeta_Keywords.Text,
             Description = this.txtDescription.Text,
             Meta_Title = this.txtMeta_Title.Text
         };
         if (!string.IsNullOrWhiteSpace(this.Hidden_SelectValue.Value))
         {
             model.ParentCategoryId = Globals.SafeInt(this.Hidden_SelectValue.Value, 0);
         }
         else
         {
             model.ParentCategoryId = 0;
         }
         if (this.bll.IsExisted(model.ParentCategoryId, model.Name, 0))
         {
             this.btnCancle.Enabled = true;
             this.btnSave.Enabled = true;
             MessageBox.ShowFailTip(this, "该分类下已存在同名分类");
         }
         else
         {
             string oldValue = string.Format("/Upload/Temp/{0}", DateTime.Now.ToString("yyyyMMdd"));
             string newValue = "/Upload/Shop/Images/Categories";
             ArrayList fileNameList = new ArrayList();
             if (!string.IsNullOrWhiteSpace(this.HiddenField_ICOPath.Value))
             {
                 string str3 = string.Format(this.HiddenField_ICOPath.Value, "");
                 fileNameList.Add(str3.Replace(oldValue, ""));
                 model.ImageUrl = str3.Replace(oldValue, newValue);
             }
             else
             {
                 model.ImageUrl = "/Content/themes/base/Shop/images/none.png";
             }
             model.AssociatedProductType = -1;
             model.RewriteName = this.txtRewriteName.Text;
             model.SKUPrefix = this.txtSKUPrefix.Text;
             model.HasChildren = false;
             if (this.bll.CreateCategory(model))
             {
                 this.btnSave.Enabled = false;
                 this.btnCancle.Enabled = false;
                 if (!string.IsNullOrWhiteSpace(this.HiddenField_ICOPath.Value))
                 {
                     FileManage.MoveFile(base.Server.MapPath(oldValue), base.Server.MapPath(newValue), fileNameList);
                 }
                 if (this.chkIsAdd.Checked)
                 {
                     this.btnCancle.Enabled = true;
                     this.btnSave.Enabled = true;
                     base.Cache.Remove("GetAllCateList-CateList");
                     MessageBox.ShowSuccessTip(this, "添加成功");
                     this.txtCategoryText.Text = this.Hidden_SelectName.Value;
                     this.HiddenField_ICOPath.Value = "";
                     this.txtDescription.Text = this.txtMeta_Description.Text = this.txtMeta_Title.Text = "";
                     this.txtName.Text = "";
                     this.txtSKUPrefix.Text = "";
                     this.txtRewriteName.Text = "";
                     this.txtMeta_Keywords.Text = "";
                 }
                 else
                 {
                     base.Cache.Remove("GetAllCateList-CateList");
                     MessageBox.ShowSuccessTip(this, "添加成功!", "list.aspx");
                 }
             }
             else
             {
                 this.btnSave.Enabled = false;
                 this.btnCancle.Enabled = false;
                 MessageBox.ShowSuccessTip(this, "添加失败!");
             }
         }
     }
 }