Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Dianda.Model.Cash_Account_Subscription model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Cash_Account_Subscription(");
            strSql.Append("AccountID,ApplyDatetime,Subscription)");
            strSql.Append(" values (");
            strSql.Append("@AccountID,@ApplyDatetime,@Subscription)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AccountID",     SqlDbType.Int,       4),
                new SqlParameter("@ApplyDatetime", SqlDbType.DateTime),
                new SqlParameter("@Subscription",  SqlDbType.Float, 8)
            };
            parameters[0].Value = model.AccountID;
            parameters[1].Value = model.ApplyDatetime;
            parameters[2].Value = model.Subscription;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Dianda.Model.Cash_Account_Subscription model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Cash_Account_Subscription set ");
            strSql.Append("AccountID=@AccountID,");
            strSql.Append("ApplyDatetime=@ApplyDatetime,");
            strSql.Append("Subscription=@Subscription");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AccountID",     SqlDbType.Int,       4),
                new SqlParameter("@ApplyDatetime", SqlDbType.DateTime),
                new SqlParameter("@Subscription",  SqlDbType.Float,     8),
                new SqlParameter("@id",            SqlDbType.Int, 4)
            };
            parameters[0].Value = model.AccountID;
            parameters[1].Value = model.ApplyDatetime;
            parameters[2].Value = model.Subscription;
            parameters[3].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Dianda.Model.Cash_Account_Subscription GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,AccountID,ApplyDatetime,Subscription from Cash_Account_Subscription ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AccountID"] != null && ds.Tables[0].Rows[0]["AccountID"].ToString() != "")
                {
                    model.AccountID = int.Parse(ds.Tables[0].Rows[0]["AccountID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ApplyDatetime"] != null && ds.Tables[0].Rows[0]["ApplyDatetime"].ToString() != "")
                {
                    model.ApplyDatetime = DateTime.Parse(ds.Tables[0].Rows[0]["ApplyDatetime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Subscription"] != null && ds.Tables[0].Rows[0]["Subscription"].ToString() != "")
                {
                    model.Subscription = decimal.Parse(ds.Tables[0].Rows[0]["Subscription"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }