Beispiel #1
0
        /// <summary>
        ///     得到一个对象实体
        /// </summary>
        public Model.Order.Cardwithhold GetModel(int id)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            var     model = new Model.Order.Cardwithhold();
            DataSet ds    = DbHelperSQL.RunProcedure("proc_cardwithhold_GetModel", parameters, "ds");

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            return(null);
        }
Beispiel #2
0
        /// <summary>
        ///     更新一条数据
        /// </summary>
        public bool Update(Model.Order.Cardwithhold model)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",         SqlDbType.Int,        4),
                new SqlParameter("@userid",     SqlDbType.Int,        4),
                new SqlParameter("@cardtype",   SqlDbType.Int,        4),
                new SqlParameter("@cardno",     SqlDbType.VarChar,   40),
                new SqlParameter("@cardpwd",    SqlDbType.VarChar,   40),
                new SqlParameter("@source",     SqlDbType.TinyInt,    1),
                new SqlParameter("@status",     SqlDbType.TinyInt,    1),
                new SqlParameter("@facevalue",  SqlDbType.Decimal,    9),
                new SqlParameter("@settle",     SqlDbType.Decimal,    9),
                new SqlParameter("@withhold",   SqlDbType.Decimal,    9),
                new SqlParameter("@backamt",    SqlDbType.Decimal,    9),
                new SqlParameter("@supplierid", SqlDbType.Int,        4),
                new SqlParameter("@supprate",   SqlDbType.Decimal,    9),
                new SqlParameter("@addtime",    SqlDbType.DateTime),
                new SqlParameter("@updatetime", SqlDbType.DateTime)
            };
            parameters[0].Value  = model.id;
            parameters[1].Value  = model.userid;
            parameters[2].Value  = model.cardtype;
            parameters[3].Value  = model.cardno;
            parameters[4].Value  = model.cardpwd;
            parameters[5].Value  = model.source;
            parameters[6].Value  = model.status;
            parameters[7].Value  = model.facevalue;
            parameters[8].Value  = model.settle;
            parameters[9].Value  = model.withhold;
            parameters[10].Value = model.backamt;
            parameters[11].Value = model.supplierid;
            parameters[12].Value = model.supprate;
            parameters[13].Value = model.addtime;
            parameters[14].Value = model.updatetime;

            DbHelperSQL.RunProcedure("proc_cardwithhold_Update", parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        /// <summary>
        ///     得到一个对象实体
        /// </summary>
        public Model.Order.Cardwithhold DataRowToModel(DataRow row)
        {
            var model = new Model.Order.Cardwithhold();

            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["userid"] != null && row["userid"].ToString() != "")
                {
                    model.userid = int.Parse(row["userid"].ToString());
                }
                if (row["cardtype"] != null && row["cardtype"].ToString() != "")
                {
                    model.cardtype = int.Parse(row["cardtype"].ToString());
                }
                if (row["cardno"] != null)
                {
                    model.cardno = row["cardno"].ToString();
                }
                if (row["cardpwd"] != null)
                {
                    model.cardpwd = row["cardpwd"].ToString();
                }
                if (row["source"] != null && row["source"].ToString() != "")
                {
                    model.source = int.Parse(row["source"].ToString());
                }
                if (row["status"] != null && row["status"].ToString() != "")
                {
                    model.status = int.Parse(row["status"].ToString());
                }
                if (row["facevalue"] != null && row["facevalue"].ToString() != "")
                {
                    model.facevalue = decimal.Parse(row["facevalue"].ToString());
                }
                if (row["settle"] != null && row["settle"].ToString() != "")
                {
                    model.settle = decimal.Parse(row["settle"].ToString());
                }
                if (row["withhold"] != null && row["withhold"].ToString() != "")
                {
                    model.withhold = decimal.Parse(row["withhold"].ToString());
                }
                if (row["backamt"] != null && row["backamt"].ToString() != "")
                {
                    model.backamt = decimal.Parse(row["backamt"].ToString());
                }
                if (row["supplierid"] != null && row["supplierid"].ToString() != "")
                {
                    model.supplierid = int.Parse(row["supplierid"].ToString());
                }
                if (row["supprate"] != null && row["supprate"].ToString() != "")
                {
                    model.supprate = decimal.Parse(row["supprate"].ToString());
                }
                if (row["addtime"] != null && row["addtime"].ToString() != "")
                {
                    model.addtime = DateTime.Parse(row["addtime"].ToString());
                }
                if (row["updatetime"] != null && row["updatetime"].ToString() != "")
                {
                    model.updatetime = DateTime.Parse(row["updatetime"].ToString());
                }
            }
            return(model);
        }