Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(yny_002.Model.C_Code model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update C_Code set ");
            strSql.Append("C_CodeID=@C_CodeID,");
            strSql.Append("C_CJCodeID=@C_CJCodeID,");
            strSql.Append("C_GType=@C_GType,");
            strSql.Append("C_State=@C_State,");
            strSql.Append("C_Path=@C_Path,");
            strSql.Append("C_Create=@C_Create");
            strSql.Append(" where C_ID=@C_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@C_CodeID",   SqlDbType.Int,         4),
                new SqlParameter("@C_CJCodeID", SqlDbType.VarChar,   250),
                new SqlParameter("@C_GType",    SqlDbType.Int,         4),
                new SqlParameter("@C_State",    SqlDbType.Int,         4),
                new SqlParameter("@C_Path",     SqlDbType.VarChar,   500),
                new SqlParameter("@C_Create",   SqlDbType.DateTime),
                new SqlParameter("@C_ID",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.C_CodeID;
            parameters[1].Value = model.C_CJCodeID;
            parameters[2].Value = model.C_GType;
            parameters[3].Value = model.C_State;
            parameters[4].Value = model.C_Path;
            parameters[5].Value = model.C_Create;
            parameters[6].Value = model.C_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static int Add(yny_002.Model.C_Code model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into C_Code(");
            strSql.Append("C_CodeID,C_CJCodeID,C_GType,C_State,C_Path,C_Create)");
            strSql.Append(" values (");
            strSql.Append("@C_CodeID,@C_CJCodeID,@C_GType,@C_State,@C_Path,@C_Create)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@C_CodeID",   SqlDbType.Int,       4),
                new SqlParameter("@C_CJCodeID", SqlDbType.VarChar, 250),
                new SqlParameter("@C_GType",    SqlDbType.Int,       4),
                new SqlParameter("@C_State",    SqlDbType.Int,       4),
                new SqlParameter("@C_Path",     SqlDbType.VarChar, 500),
                new SqlParameter("@C_Create",   SqlDbType.DateTime)
            };
            parameters[0].Value = model.C_CodeID;
            parameters[1].Value = model.C_CJCodeID;
            parameters[2].Value = model.C_GType;
            parameters[3].Value = model.C_State;
            parameters[4].Value = model.C_Path;
            parameters[5].Value = model.C_Create;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public static yny_002.Model.C_Code DataRowToModel(DataRow row)
 {
     yny_002.Model.C_Code model = new yny_002.Model.C_Code();
     if (row != null)
     {
         if (row["C_ID"] != null && row["C_ID"].ToString() != "")
         {
             model.C_ID = int.Parse(row["C_ID"].ToString());
         }
         if (row["C_CodeID"] != null && row["C_CodeID"].ToString() != "")
         {
             model.C_CodeID = int.Parse(row["C_CodeID"].ToString());
         }
         if (row["C_CJCodeID"] != null)
         {
             model.C_CJCodeID = row["C_CJCodeID"].ToString();
         }
         if (row["C_GType"] != null && row["C_GType"].ToString() != "")
         {
             model.C_GType = int.Parse(row["C_GType"].ToString());
         }
         if (row["C_State"] != null && row["C_State"].ToString() != "")
         {
             model.C_State = int.Parse(row["C_State"].ToString());
         }
         if (row["C_Path"] != null)
         {
             model.C_Path = row["C_Path"].ToString();
         }
         if (row["C_Create"] != null && row["C_Create"].ToString() != "")
         {
             model.C_Create = DateTime.Parse(row["C_Create"].ToString());
         }
     }
     return(model);
 }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static yny_002.Model.C_Code GetModel(int C_CodeID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 C_ID,C_CodeID,C_CJCodeID,C_GType,C_State,C_Path,C_Create from C_Code ");
            strSql.Append(" where C_CodeID=@C_CodeID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@C_CodeID", SqlDbType.Int, 4)
            };
            parameters[0].Value = C_CodeID;

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

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