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

            strSql.Append("update CompensationType set ");
            strSql.Append("CT_NAME=@CT_NAME");
            strSql.Append(" where CT_ID=@CT_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CT_NAME", SqlDbType.NVarChar, 20),
                new SqlParameter("@CT_ID",   SqlDbType.BigInt,    8),
                new SqlParameter("@CT_CODE", SqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.CT_NAME;
            parameters[1].Value = model.CT_ID;
            parameters[2].Value = model.CT_CODE;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(LCSS.Model.CompensationType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CompensationType(");
            strSql.Append("CT_CODE,CT_NAME)");
            strSql.Append(" values (");
            strSql.Append("@CT_CODE,@CT_NAME)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CT_CODE", SqlDbType.VarChar,  20),
                new SqlParameter("@CT_NAME", SqlDbType.NVarChar, 20)
            };
            parameters[0].Value = model.CT_CODE;
            parameters[1].Value = model.CT_NAME;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
예제 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public LCSS.Model.CompensationType DataRowToModel(DataRow row)
 {
     LCSS.Model.CompensationType model = new LCSS.Model.CompensationType();
     if (row != null)
     {
         if (row["CT_ID"] != null && row["CT_ID"].ToString() != "")
         {
             model.CT_ID = long.Parse(row["CT_ID"].ToString());
         }
         if (row["CT_CODE"] != null)
         {
             model.CT_CODE = row["CT_CODE"].ToString();
         }
         if (row["CT_NAME"] != null)
         {
             model.CT_NAME = row["CT_NAME"].ToString();
         }
     }
     return(model);
 }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LCSS.Model.CompensationType GetModel(long CT_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 CT_ID,CT_CODE,CT_NAME from CompensationType ");
            strSql.Append(" where CT_ID=@CT_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CT_ID", SqlDbType.BigInt)
            };
            parameters[0].Value = CT_ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }