Ejemplo n.º 1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Maticsoft.Model.Shop.Gift.GiftsCategory model = new Maticsoft.Model.Shop.Gift.GiftsCategory {
         Name = this.txtName.Text,
         Description = this.txtDescription.Text
     };
     if (!string.IsNullOrWhiteSpace(this.DropParentId.SelectedValue.Trim()))
     {
         model.ParentCategoryId = new int?(int.Parse(this.DropParentId.SelectedValue));
     }
     else
     {
         model.ParentCategoryId = 0;
     }
     model.Depth = 0;
     model.Path = "";
     if (this.bll.AddCategory(model))
     {
         this.btnSave.Enabled = false;
         this.btnCancle.Enabled = false;
         MessageBox.ShowSuccessTip(this, "添加成功,正在跳转...", "CategoryList.aspx");
     }
     else
     {
         this.btnSave.Enabled = false;
         this.btnCancle.Enabled = false;
         MessageBox.ShowFailTip(this, "添加失败!");
     }
 }
Ejemplo n.º 2
0
 public List<Maticsoft.Model.Shop.Gift.GiftsCategory> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Shop.Gift.GiftsCategory> list = new List<Maticsoft.Model.Shop.Gift.GiftsCategory>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Shop.Gift.GiftsCategory item = new Maticsoft.Model.Shop.Gift.GiftsCategory();
             if ((dt.Rows[i]["CategoryID"] != null) && (dt.Rows[i]["CategoryID"].ToString() != ""))
             {
                 item.CategoryID = int.Parse(dt.Rows[i]["CategoryID"].ToString());
             }
             if ((dt.Rows[i]["ParentCategoryId"] != null) && (dt.Rows[i]["ParentCategoryId"].ToString() != ""))
             {
                 item.ParentCategoryId = new int?(int.Parse(dt.Rows[i]["ParentCategoryId"].ToString()));
             }
             if ((dt.Rows[i]["Name"] != null) && (dt.Rows[i]["Name"].ToString() != ""))
             {
                 item.Name = dt.Rows[i]["Name"].ToString();
             }
             if ((dt.Rows[i]["Depth"] != null) && (dt.Rows[i]["Depth"].ToString() != ""))
             {
                 item.Depth = int.Parse(dt.Rows[i]["Depth"].ToString());
             }
             if ((dt.Rows[i]["Path"] != null) && (dt.Rows[i]["Path"].ToString() != ""))
             {
                 item.Path = dt.Rows[i]["Path"].ToString();
             }
             if ((dt.Rows[i]["DisplaySequence"] != null) && (dt.Rows[i]["DisplaySequence"].ToString() != ""))
             {
                 item.DisplaySequence = int.Parse(dt.Rows[i]["DisplaySequence"].ToString());
             }
             if ((dt.Rows[i]["Description"] != null) && (dt.Rows[i]["Description"].ToString() != ""))
             {
                 item.Description = dt.Rows[i]["Description"].ToString();
             }
             if ((dt.Rows[i]["Theme"] != null) && (dt.Rows[i]["Theme"].ToString() != ""))
             {
                 item.Theme = dt.Rows[i]["Theme"].ToString();
             }
             if ((dt.Rows[i]["HasChildren"] != null) && (dt.Rows[i]["HasChildren"].ToString() != ""))
             {
                 if ((dt.Rows[i]["HasChildren"].ToString() == "1") || (dt.Rows[i]["HasChildren"].ToString().ToLower() == "true"))
                 {
                     item.HasChildren = true;
                 }
                 else
                 {
                     item.HasChildren = false;
                 }
             }
             list.Add(item);
         }
     }
     return list;
 }
Ejemplo n.º 3
0
 public Maticsoft.Model.Shop.Gift.GiftsCategory GetModel(int CategoryID)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select  top 1 CategoryID,ParentCategoryId,Name,Depth,Path,DisplaySequence,Description,Theme,HasChildren from Shop_GiftsCategory ");
     builder.Append(" where CategoryID=@CategoryID");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@CategoryID", SqlDbType.Int, 4) };
     cmdParms[0].Value = CategoryID;
     Maticsoft.Model.Shop.Gift.GiftsCategory category = new Maticsoft.Model.Shop.Gift.GiftsCategory();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["CategoryID"] != null) && (set.Tables[0].Rows[0]["CategoryID"].ToString() != ""))
     {
         category.CategoryID = int.Parse(set.Tables[0].Rows[0]["CategoryID"].ToString());
     }
     if ((set.Tables[0].Rows[0]["ParentCategoryId"] != null) && (set.Tables[0].Rows[0]["ParentCategoryId"].ToString() != ""))
     {
         category.ParentCategoryId = new int?(int.Parse(set.Tables[0].Rows[0]["ParentCategoryId"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["Name"] != null) && (set.Tables[0].Rows[0]["Name"].ToString() != ""))
     {
         category.Name = set.Tables[0].Rows[0]["Name"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Depth"] != null) && (set.Tables[0].Rows[0]["Depth"].ToString() != ""))
     {
         category.Depth = int.Parse(set.Tables[0].Rows[0]["Depth"].ToString());
     }
     if ((set.Tables[0].Rows[0]["Path"] != null) && (set.Tables[0].Rows[0]["Path"].ToString() != ""))
     {
         category.Path = set.Tables[0].Rows[0]["Path"].ToString();
     }
     if ((set.Tables[0].Rows[0]["DisplaySequence"] != null) && (set.Tables[0].Rows[0]["DisplaySequence"].ToString() != ""))
     {
         category.DisplaySequence = int.Parse(set.Tables[0].Rows[0]["DisplaySequence"].ToString());
     }
     if ((set.Tables[0].Rows[0]["Description"] != null) && (set.Tables[0].Rows[0]["Description"].ToString() != ""))
     {
         category.Description = set.Tables[0].Rows[0]["Description"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Theme"] != null) && (set.Tables[0].Rows[0]["Theme"].ToString() != ""))
     {
         category.Theme = set.Tables[0].Rows[0]["Theme"].ToString();
     }
     if ((set.Tables[0].Rows[0]["HasChildren"] != null) && (set.Tables[0].Rows[0]["HasChildren"].ToString() != ""))
     {
         if ((set.Tables[0].Rows[0]["HasChildren"].ToString() == "1") || (set.Tables[0].Rows[0]["HasChildren"].ToString().ToLower() == "true"))
         {
             category.HasChildren = true;
             return category;
         }
         category.HasChildren = false;
     }
     return category;
 }