/// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(IPSP.Model.TCode_BillTemplateColumn model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TCode_BillTemplateColumn(");
            strSql.Append("s_ColumnName,n_BillTemplateID,n_Width,n_OrderNum)");
            strSql.Append(" values (");
            strSql.Append("@s_ColumnName,@n_BillTemplateID,@n_Width,@n_OrderNum)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@s_ColumnName",     SqlDbType.NVarChar, 50),
                new SqlParameter("@n_BillTemplateID", SqlDbType.Int,       4),
                new SqlParameter("@n_Width",          SqlDbType.Decimal,   9),
                new SqlParameter("@n_OrderNum",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.s_ColumnName;
            parameters[1].Value = model.n_BillTemplateID;
            parameters[2].Value = model.n_Width;
            parameters[3].Value = model.n_OrderNum;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public IPSP.Model.TCode_BillTemplateColumn DataRowToModel(DataRow row)
 {
     IPSP.Model.TCode_BillTemplateColumn model = new IPSP.Model.TCode_BillTemplateColumn();
     if (row != null)
     {
         if (row["n_ID"] != null && row["n_ID"].ToString() != "")
         {
             model.n_ID = int.Parse(row["n_ID"].ToString());
         }
         if (row["s_ColumnName"] != null)
         {
             model.s_ColumnName = row["s_ColumnName"].ToString();
         }
         if (row["n_BillTemplateID"] != null && row["n_BillTemplateID"].ToString() != "")
         {
             model.n_BillTemplateID = int.Parse(row["n_BillTemplateID"].ToString());
         }
         if (row["n_Width"] != null && row["n_Width"].ToString() != "")
         {
             model.n_Width = decimal.Parse(row["n_Width"].ToString());
         }
         if (row["n_OrderNum"] != null && row["n_OrderNum"].ToString() != "")
         {
             model.n_OrderNum = int.Parse(row["n_OrderNum"].ToString());
         }
     }
     return(model);
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(IPSP.Model.TCode_BillTemplateColumn model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TCode_BillTemplateColumn set ");
            strSql.Append("s_ColumnName=@s_ColumnName,");
            strSql.Append("n_Width=@n_Width,");
            strSql.Append("n_OrderNum=@n_OrderNum");
            strSql.Append(" where n_ID=@n_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@s_ColumnName",     SqlDbType.NVarChar, 50),
                new SqlParameter("@n_Width",          SqlDbType.Decimal,   9),
                new SqlParameter("@n_OrderNum",       SqlDbType.Int,       4),
                new SqlParameter("@n_ID",             SqlDbType.Int,       4),
                new SqlParameter("@n_BillTemplateID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.s_ColumnName;
            parameters[1].Value = model.n_Width;
            parameters[2].Value = model.n_OrderNum;
            parameters[3].Value = model.n_ID;
            parameters[4].Value = model.n_BillTemplateID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public IPSP.Model.TCode_BillTemplateColumn GetModel(int n_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 n_ID,s_ColumnName,n_BillTemplateID,n_Width,n_OrderNum from TCode_BillTemplateColumn ");
            strSql.Append(" where n_ID=@n_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@n_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = n_ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(IPSP.Model.TCode_BillTemplateColumn model)
 {
     return(dal.Update(model));
 }
Пример #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(IPSP.Model.TCode_BillTemplateColumn model)
 {
     return(dal.Add(model));
 }