示例#1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Hownet.Model.MoneyList GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,KJKMID,DateTime,InMoney,OutMoney,Money,TableID,TypeID,Remark from MoneyList ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Hownet.Model.MoneyList model = new Hownet.Model.MoneyList();
            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]["KJKMID"] != null && ds.Tables[0].Rows[0]["KJKMID"].ToString() != "")
                {
                    model.KJKMID = int.Parse(ds.Tables[0].Rows[0]["KJKMID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DateTime"] != null && ds.Tables[0].Rows[0]["DateTime"].ToString() != "")
                {
                    model.DateTime = DateTime.Parse(ds.Tables[0].Rows[0]["DateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["InMoney"] != null && ds.Tables[0].Rows[0]["InMoney"].ToString() != "")
                {
                    model.InMoney = decimal.Parse(ds.Tables[0].Rows[0]["InMoney"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OutMoney"] != null && ds.Tables[0].Rows[0]["OutMoney"].ToString() != "")
                {
                    model.OutMoney = decimal.Parse(ds.Tables[0].Rows[0]["OutMoney"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Money"] != null && ds.Tables[0].Rows[0]["Money"].ToString() != "")
                {
                    model.Money = decimal.Parse(ds.Tables[0].Rows[0]["Money"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TableID"] != null && ds.Tables[0].Rows[0]["TableID"].ToString() != "")
                {
                    model.TableID = int.Parse(ds.Tables[0].Rows[0]["TableID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TypeID"] != null && ds.Tables[0].Rows[0]["TypeID"].ToString() != "")
                {
                    model.TypeID = int.Parse(ds.Tables[0].Rows[0]["TypeID"].ToString());
                }
                model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                model.A      = 1;
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hownet.Model.MoneyList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update MoneyList set ");
            strSql.Append("KJKMID=@KJKMID,");
            strSql.Append("DateTime=@DateTime,");
            strSql.Append("InMoney=@InMoney,");
            strSql.Append("OutMoney=@OutMoney,");
            strSql.Append("Money=@Money,");
            strSql.Append("TableID=@TableID,");
            strSql.Append("TypeID=@TypeID,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@KJKMID",   SqlDbType.Int,          4),
                new SqlParameter("@DateTime", SqlDbType.DateTime),
                new SqlParameter("@InMoney",  SqlDbType.Decimal,      9),
                new SqlParameter("@OutMoney", SqlDbType.Decimal,      9),
                new SqlParameter("@Money",    SqlDbType.Decimal,      9),
                new SqlParameter("@TableID",  SqlDbType.Int,          4),
                new SqlParameter("@TypeID",   SqlDbType.Int,          4),
                new SqlParameter("@Remark",   SqlDbType.NVarChar,  4000),
                new SqlParameter("@ID",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.KJKMID;
            parameters[1].Value = model.DateTime;
            parameters[2].Value = model.InMoney;
            parameters[3].Value = model.OutMoney;
            parameters[4].Value = model.Money;
            parameters[5].Value = model.TableID;
            parameters[6].Value = model.TypeID;
            parameters[7].Value = model.Remark;
            parameters[8].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hownet.Model.MoneyList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into MoneyList(");
            strSql.Append("KJKMID,DateTime,InMoney,OutMoney,Money,TableID,TypeID,Remark)");
            strSql.Append(" values (");
            strSql.Append("@KJKMID,@DateTime,@InMoney,@OutMoney,@Money,@TableID,@TypeID,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@KJKMID",   SqlDbType.Int,       4),
                new SqlParameter("@DateTime", SqlDbType.DateTime),
                new SqlParameter("@InMoney",  SqlDbType.Decimal,   9),
                new SqlParameter("@OutMoney", SqlDbType.Decimal,   9),
                new SqlParameter("@Money",    SqlDbType.Decimal,   9),
                new SqlParameter("@TableID",  SqlDbType.Int,       4),
                new SqlParameter("@TypeID",   SqlDbType.Int,       4),
                new SqlParameter("@Remark",   SqlDbType.NVarChar, 4000)
            };
            parameters[0].Value = model.KJKMID;
            parameters[1].Value = model.DateTime;
            parameters[2].Value = model.InMoney;
            parameters[3].Value = model.OutMoney;
            parameters[4].Value = model.Money;
            parameters[5].Value = model.TableID;
            parameters[6].Value = model.TypeID;
            parameters[7].Value = model.Remark;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }