Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static int Add(yny_003.Model.C_Security model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into C_Security(");
            strSql.Append("CarID,JCMID,JCType,CreateDate)");
            strSql.Append(" values (");
            strSql.Append("@CarID,@JCMID,@JCType,@CreateDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CarID",      SqlDbType.Int,       4),
                new SqlParameter("@JCMID",      SqlDbType.VarChar,  50),
                new SqlParameter("@JCType",     SqlDbType.VarChar, 250),
                new SqlParameter("@CreateDate", SqlDbType.DateTime)
            };
            parameters[0].Value = model.CarID;
            parameters[1].Value = model.JCMID;
            parameters[2].Value = model.JCType;
            parameters[3].Value = model.CreateDate;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public static yny_003.Model.C_Security DataRowToModel(DataRow row)
 {
     yny_003.Model.C_Security model = new yny_003.Model.C_Security();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["CarID"] != null && row["CarID"].ToString() != "")
         {
             model.CarID = int.Parse(row["CarID"].ToString());
         }
         if (row["JCMID"] != null)
         {
             model.JCMID = row["JCMID"].ToString();
         }
         if (row["JCType"] != null)
         {
             model.JCType = row["JCType"].ToString();
         }
         if (row["CreateDate"] != null && row["CreateDate"].ToString() != "")
         {
             model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(yny_003.Model.C_Security model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update C_Security set ");
            strSql.Append("CarID=@CarID,");
            strSql.Append("JCMID=@JCMID,");
            strSql.Append("JCType=@JCType,");
            strSql.Append("CreateDate=@CreateDate");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CarID",      SqlDbType.Int,         4),
                new SqlParameter("@JCMID",      SqlDbType.VarChar,    50),
                new SqlParameter("@JCType",     SqlDbType.VarChar,   250),
                new SqlParameter("@CreateDate", SqlDbType.DateTime),
                new SqlParameter("@ID",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CarID;
            parameters[1].Value = model.JCMID;
            parameters[2].Value = model.JCType;
            parameters[3].Value = model.CreateDate;
            parameters[4].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static yny_003.Model.C_Security GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,CarID,JCMID,JCType,CreateDate from C_Security ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

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