Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BWJS.Model.CompanyCategory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dbo.[CompanyCategory](");
            strSql.Append("CompanyCategoryName,OrderId,IsDeleted,CreateId,CreateDate,EditId,EditDate");
            strSql.Append(") values (");
            strSql.Append("@CompanyCategoryName,@OrderId,@IsDeleted,@CreateId,@CreateDate,@EditId,@EditDate");
            strSql.Append(") ");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CompanyCategoryName", model.CompanyCategoryName),
                new SqlParameter("@OrderId",             model.OrderId),
                new SqlParameter("@IsDeleted",           model.IsDeleted),
                new SqlParameter("@CreateId",            model.CreateId),
                new SqlParameter("@CreateDate",          model.CreateDate),
                new SqlParameter("@EditId",              model.EditId),
                new SqlParameter("@EditDate",            model.EditDate)
            };


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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BWJS.Model.CompanyCategory GetModel(int CompanyCategoryId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select CompanyCategoryId, CompanyCategoryName, OrderId, IsDeleted, CreateId, CreateDate, EditId, EditDate  ");
            strSql.Append("  from dbo.[CompanyCategory] ");
            strSql.Append(" where CompanyCategoryId=@CompanyCategoryId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CompanyCategoryId", SqlDbType.Int, 4)
            };
            parameters[0].Value = CompanyCategoryId;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// datarow转成对象实体
        /// </summary>
        public BWJS.Model.CompanyCategory DataRowToModel(DataRow row)
        {
            BWJS.Model.CompanyCategory model = new BWJS.Model.CompanyCategory();

            if (row != null)
            {
                if (row["CompanyCategoryId"].ToString() != "")
                {
                    model.CompanyCategoryId = int.Parse(row["CompanyCategoryId"].ToString());
                }
                model.CompanyCategoryName = row["CompanyCategoryName"].ToString();
                if (row["OrderId"].ToString() != "")
                {
                    model.OrderId = int.Parse(row["OrderId"].ToString());
                }
                if (row["IsDeleted"].ToString() != "")
                {
                    model.IsDeleted = int.Parse(row["IsDeleted"].ToString());
                }
                if (row["CreateId"].ToString() != "")
                {
                    model.CreateId = int.Parse(row["CreateId"].ToString());
                }
                if (row["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                }
                if (row["EditId"].ToString() != "")
                {
                    model.EditId = int.Parse(row["EditId"].ToString());
                }
                if (row["EditDate"].ToString() != "")
                {
                    model.EditDate = DateTime.Parse(row["EditDate"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BWJS.Model.CompanyCategory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dbo.[CompanyCategory] set ");

            strSql.Append(" CompanyCategoryName = @CompanyCategoryName , ");
            strSql.Append(" OrderId = @OrderId , ");
            strSql.Append(" IsDeleted = @IsDeleted , ");
            strSql.Append(" CreateId = @CreateId , ");
            strSql.Append(" CreateDate = @CreateDate , ");
            strSql.Append(" EditId = @EditId , ");
            strSql.Append(" EditDate = @EditDate  ");
            strSql.Append(" where CompanyCategoryId=@CompanyCategoryId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@CompanyCategoryId",   model.CompanyCategoryId),
                new SqlParameter("@CompanyCategoryName", model.CompanyCategoryName),
                new SqlParameter("@OrderId",             model.OrderId),
                new SqlParameter("@IsDeleted",           model.IsDeleted),
                new SqlParameter("@CreateId",            model.CreateId),
                new SqlParameter("@CreateDate",          model.CreateDate),
                new SqlParameter("@EditId",              model.EditId),
                new SqlParameter("@EditDate",            model.EditDate)
            };

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BWJS.Model.CompanyCategory model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(BWJS.Model.CompanyCategory model)
 {
     return(dal.Add(model));
 }