Exemple #1
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(PayPriceConver model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.Int,       4),
                new SqlParameter("@Pri_Type",     SqlDbType.Int,       4),
                new SqlParameter("@Value",        SqlDbType.Money,     8),
                new SqlParameter("@Conv_PriType", SqlDbType.Int,       4),
                new SqlParameter("@Created",      SqlDbType.DateTime),
                new SqlParameter("@IsOpen",       SqlDbType.Bit)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.Pri_Type;
            parameters[2].Value     = model.Value;
            parameters[3].Value     = model.Conv_PriType;
            parameters[4].Value     = model.Created;
            parameters[5].Value     = model.IsOpen;

            rowsAffected = DataBase.RunProc("PayPriceConver_ADD", parameters);
            if (rowsAffected > 0)
            {
                return((int)parameters[0].Value);
            }
            else
            {
                return(0);
            }
        }
Exemple #2
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(PayPriceConver model)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.Int,       4),
                new SqlParameter("@Pri_Type",     SqlDbType.Int,       4),
                new SqlParameter("@Value",        SqlDbType.Money,     8),
                new SqlParameter("@Conv_PriType", SqlDbType.Int,       4),
                new SqlParameter("@Created",      SqlDbType.DateTime),
                new SqlParameter("@IsOpen",       SqlDbType.Bit)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.Pri_Type;
            parameters[2].Value = model.Value;
            parameters[3].Value = model.Conv_PriType;
            parameters[4].Value = model.Created;
            parameters[5].Value = model.IsOpen;

            rowsAffected = DataBase.RunProc("PayPriceConver_Update", parameters);
            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <param name="pay"></param>
        /// <returns></returns>
        public PayPriceConver GetModel(int pay, decimal value)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@value", SqlDbType.Money, 8),
                new SqlParameter("@pay",   SqlDbType.Int, 4)
            };
            parameters[0].Value = value;
            parameters[1].Value = pay;

            PayPriceConver model = new PayPriceConver();
            DataSet        ds    = null;

            DataBase.RunProc("PayPriceConver_GetModelByPayType", parameters, out ds);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Pri_Type"].ToString() != "")
                {
                    model.Pri_Type = int.Parse(ds.Tables[0].Rows[0]["Pri_Type"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Value"].ToString() != "")
                {
                    model.Value = decimal.Parse(ds.Tables[0].Rows[0]["Value"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Conv_PriType"].ToString() != "")
                {
                    model.Conv_PriType = int.Parse(ds.Tables[0].Rows[0]["Conv_PriType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Created"].ToString() != "")
                {
                    model.Created = DateTime.Parse(ds.Tables[0].Rows[0]["Created"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsOpen"].ToString() != "")
                {
                    model.IsOpen = bool.Parse(ds.Tables[0].Rows[0]["IsOpen"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }