Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static int Add(yny_005.Model.C_SuppBank model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into C_SuppBank(");
            strSql.Append("AccountName,Money,CardName,BankName,Spare)");
            strSql.Append(" values (");
            strSql.Append("@AccountName,@Money,@CardName,@BankName,@Spare)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AccountName", SqlDbType.VarChar, 50),
                new SqlParameter("@Money",       SqlDbType.Decimal,  9),
                new SqlParameter("@CardName",    SqlDbType.VarChar, 50),
                new SqlParameter("@BankName",    SqlDbType.VarChar, 50),
                new SqlParameter("@Spare",       SqlDbType.VarChar, 250)
            };
            parameters[0].Value = model.AccountName;
            parameters[1].Value = model.Money;
            parameters[2].Value = model.CardName;
            parameters[3].Value = model.BankName;
            parameters[4].Value = model.Spare;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public static yny_005.Model.C_SuppBank DataRowToModel(DataRow row)
 {
     yny_005.Model.C_SuppBank model = new yny_005.Model.C_SuppBank();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["AccountName"] != null)
         {
             model.AccountName = row["AccountName"].ToString();
         }
         if (row["Money"] != null && row["Money"].ToString() != "")
         {
             model.Money = decimal.Parse(row["Money"].ToString());
         }
         if (row["CardName"] != null)
         {
             model.CardName = row["CardName"].ToString();
         }
         if (row["BankName"] != null)
         {
             model.BankName = row["BankName"].ToString();
         }
         if (row["Spare"] != null)
         {
             model.Spare = row["Spare"].ToString();
         }
     }
     return(model);
 }
Example #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(yny_005.Model.C_SuppBank model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update C_SuppBank set ");
            strSql.Append("AccountName=@AccountName,");
            strSql.Append("Money=@Money,");
            strSql.Append("CardName=@CardName,");
            strSql.Append("BankName=@BankName,");
            strSql.Append("Spare=@Spare");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AccountName", SqlDbType.VarChar,  50),
                new SqlParameter("@Money",       SqlDbType.Decimal,   9),
                new SqlParameter("@CardName",    SqlDbType.VarChar,  50),
                new SqlParameter("@BankName",    SqlDbType.VarChar,  50),
                new SqlParameter("@Spare",       SqlDbType.VarChar, 250),
                new SqlParameter("@ID",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.AccountName;
            parameters[1].Value = model.Money;
            parameters[2].Value = model.CardName;
            parameters[3].Value = model.BankName;
            parameters[4].Value = model.Spare;
            parameters[5].Value = model.ID;

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

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

            strSql.Append("select  top 1 ID,AccountName,Money,CardName,BankName,Spare from C_SuppBank ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

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