コード例 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(IPSP.Model.TCCase_TortiousWare model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TCCase_TortiousWare(");
            strSql.Append("n_CaseID,s_WareName,s_HSCode,s_Note)");
            strSql.Append(" values (");
            strSql.Append("@n_CaseID,@s_WareName,@s_HSCode,@s_Note)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@n_CaseID",   SqlDbType.Int,        4),
                new SqlParameter("@s_WareName", SqlDbType.NVarChar, 300),
                new SqlParameter("@s_HSCode",   SqlDbType.NVarChar,  30),
                new SqlParameter("@s_Note",     SqlDbType.NVarChar, 600)
            };
            parameters[0].Value = model.n_CaseID;
            parameters[1].Value = model.s_WareName;
            parameters[2].Value = model.s_HSCode;
            parameters[3].Value = model.s_Note;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public IPSP.Model.TCCase_TortiousWare DataRowToModel(DataRow row)
 {
     IPSP.Model.TCCase_TortiousWare model = new IPSP.Model.TCCase_TortiousWare();
     if (row != null)
     {
         if (row["n_CaseID"] != null && row["n_CaseID"].ToString() != "")
         {
             model.n_CaseID = int.Parse(row["n_CaseID"].ToString());
         }
         if (row["s_WareName"] != null)
         {
             model.s_WareName = row["s_WareName"].ToString();
         }
         if (row["s_HSCode"] != null)
         {
             model.s_HSCode = row["s_HSCode"].ToString();
         }
         if (row["s_Note"] != null)
         {
             model.s_Note = row["s_Note"].ToString();
         }
         if (row["n_ID"] != null && row["n_ID"].ToString() != "")
         {
             model.n_ID = int.Parse(row["n_ID"].ToString());
         }
     }
     return(model);
 }
コード例 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(IPSP.Model.TCCase_TortiousWare model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TCCase_TortiousWare set ");
            strSql.Append("s_WareName=@s_WareName,");
            strSql.Append("s_HSCode=@s_HSCode,");
            strSql.Append("s_Note=@s_Note");
            strSql.Append(" where n_ID=@n_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@s_WareName", SqlDbType.NVarChar, 300),
                new SqlParameter("@s_HSCode",   SqlDbType.NVarChar,  30),
                new SqlParameter("@s_Note",     SqlDbType.NVarChar, 600),
                new SqlParameter("@n_CaseID",   SqlDbType.Int,        4),
                new SqlParameter("@n_ID",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.s_WareName;
            parameters[1].Value = model.s_HSCode;
            parameters[2].Value = model.s_Note;
            parameters[3].Value = model.n_CaseID;
            parameters[4].Value = model.n_ID;

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

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

            strSql.Append("select  top 1 n_CaseID,s_WareName,s_HSCode,s_Note,n_ID from TCCase_TortiousWare ");
            strSql.Append(" where n_ID=@n_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@n_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = n_ID;

            IPSP.Model.TCCase_TortiousWare model = new IPSP.Model.TCCase_TortiousWare();
            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.TCCase_TortiousWare model)
 {
     return(dal.Update(model));
 }
コード例 #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(IPSP.Model.TCCase_TortiousWare model)
 {
     return(dal.Add(model));
 }