예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(VipSoft.Model.GoodsClass model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update GoodsClass set ");
            strSql.Append("ClassName=@ClassName,");
            strSql.Append("ParentID=@ParentID,");
            strSql.Append("ShopID=@ShopID,");
            strSql.Append("ShopName=@ShopName");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ClassName", SqlDbType.VarChar, 50),
                new SqlParameter("@ParentID",  SqlDbType.Int,      4),
                new SqlParameter("@ShopID",    SqlDbType.Int,      4),
                new SqlParameter("@ShopName",  SqlDbType.VarChar, 50),
                new SqlParameter("@ID",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ClassName;
            parameters[1].Value = model.ParentID;
            parameters[2].Value = model.ShopID;
            parameters[3].Value = model.ShopName;
            parameters[4].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public VipSoft.Model.GoodsClass DataRowToModel(DataRow row)
 {
     VipSoft.Model.GoodsClass model=new VipSoft.Model.GoodsClass();
     if (row != null)
     {
         if(row["ID"]!=null && row["ID"].ToString()!="")
         {
             model.ID=int.Parse(row["ID"].ToString());
         }
         if(row["ClassName"]!=null)
         {
             model.ClassName=row["ClassName"].ToString();
         }
         if(row["ParentID"]!=null && row["ParentID"].ToString()!="")
         {
             model.ParentID=int.Parse(row["ParentID"].ToString());
         }
         if(row["ShopID"]!=null && row["ShopID"].ToString()!="")
         {
             model.ShopID=int.Parse(row["ShopID"].ToString());
         }
         if(row["ShopName"]!=null)
         {
             model.ShopName=row["ShopName"].ToString();
         }
     }
     return model;
 }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(VipSoft.Model.GoodsClass model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into GoodsClass(");
            strSql.Append("ClassName,ParentID,ShopID,ShopName)");
            strSql.Append(" values (");
            strSql.Append("@ClassName,@ParentID,@ShopID,@ShopName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ClassName", SqlDbType.VarChar, 50),
                new SqlParameter("@ParentID",  SqlDbType.Int,      4),
                new SqlParameter("@ShopID",    SqlDbType.Int,      4),
                new SqlParameter("@ShopName",  SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.ClassName;
            parameters[1].Value = model.ParentID;
            parameters[2].Value = model.ShopID;
            parameters[3].Value = model.ShopName;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public VipSoft.Model.GoodsClass DataRowToModel(DataRow row)
 {
     VipSoft.Model.GoodsClass model = new VipSoft.Model.GoodsClass();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["ClassName"] != null)
         {
             model.ClassName = row["ClassName"].ToString();
         }
         if (row["ParentID"] != null && row["ParentID"].ToString() != "")
         {
             model.ParentID = int.Parse(row["ParentID"].ToString());
         }
         if (row["ShopID"] != null && row["ShopID"].ToString() != "")
         {
             model.ShopID = int.Parse(row["ShopID"].ToString());
         }
         if (row["ShopName"] != null)
         {
             model.ShopName = row["ShopName"].ToString();
         }
     }
     return(model);
 }
예제 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VipSoft.Model.GoodsClass GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,ClassName,ParentID,ShopID,ShopName from GoodsClass ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            VipSoft.Model.GoodsClass model = new VipSoft.Model.GoodsClass();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VipSoft.Model.GoodsClass GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,ClassName,ParentID,ShopID,ShopName from GoodsClass ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)
            };
            parameters[0].Value = ID;

            VipSoft.Model.GoodsClass model=new VipSoft.Model.GoodsClass();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
예제 #7
0
 private void button_Add_Click(object sender, EventArgs e)
 {
     VipSoft.BLL.GoodsClass gc = new VipSoft.BLL.GoodsClass();
     if (this.textBox_ClassName.Text == "新类别" || this.textBox_ClassName.Text == "")
     {
         MessageBox.Show("请输入分类名称。");
         return;
     }
     if (this.label_ID.Text == "label_ID" && this.label_ParentID.Text == "label_ParentID")
     {
         MessageBox.Show("请先在左侧列表中选择对应操作!");
         return;
     }
     if (this.button_Add.Text == "增加分类")
     {
         if (this.label_ParentID.Text == "")
         {
             MessageBox.Show("请先在左侧列表中选择对应操作!");
             return;
         }
         VipSoft.Model.GoodsClass model = new Model.GoodsClass();
         model.ClassName = this.textBox_ClassName.Text;
         model.ParentID = int.Parse(this.label_ParentID.Text);
         model.ShopID = PublicState.Master.ShopID;
         model.ShopName = PublicState.Master.ShopName;
         gc.Add(model);
         // 写入日志
         VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog();
         log.Add(new VipSoft.Model.SysLog(PublicState.Master, "商品分类管理",
             string.Format("增加分类成功,名称:{0}父类:{1}", this.textBox_ClassName.Text, this.textBox_Parent.Text),
             DateTime.Now));
         // 文本框清空
         this.label_ID.Text = "";
         this.label_ParentID.Text = "";
         this.textBox_Parent.Text = "";
         this.textBox_ClassName.Text = "";
     }
     else
     {
         VipSoft.Model.GoodsClass gci = new VipSoft.Model.GoodsClass();
         gci.ClassName = this.textBox_ClassName.Text.Trim();
         gci.ID = int.Parse(this.label_ID.Text);
         gc.Update(gci);
         // 写入日志
         VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog();
         log.Add(new VipSoft.Model.SysLog(PublicState.Master, "商品分类管理",
             string.Format("修改分类成功,名称:{0}父类:{1}", this.textBox_ClassName.Text, this.textBox_Parent.Text),
             DateTime.Now));
     }
     // 重新绑定
     BindClass();
 }