Ejemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public t_procurement_records DataRowToModel(DataRow row)
        {
            t_procurement_records model = new t_procurement_records();

            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["goodsName"] != null)
                {
                    model.goodsName = row["goodsName"].ToString();
                }
                if (row["kind"] != null)
                {
                    model.kind = row["kind"].ToString();
                }
                if (row["buyTime"] != null && row["buyTime"].ToString() != "")
                {
                    model.buyTime = DateTime.Parse(row["buyTime"].ToString());
                }
                if (row["buyCount"] != null && row["buyCount"].ToString() != "")
                {
                    model.buyCount = int.Parse(row["buyCount"].ToString());
                }
                if (row["buyPrice"] != null && row["buyPrice"].ToString() != "")
                {
                    model.buyPrice = decimal.Parse(row["buyPrice"].ToString());
                }
                if (row["freight"] != null && row["freight"].ToString() != "")
                {
                    model.freight = decimal.Parse(row["freight"].ToString());
                }
                if (row["otherMoney"] != null && row["otherMoney"].ToString() != "")
                {
                    model.otherMoney = decimal.Parse(row["otherMoney"].ToString());
                }
                if (row["totalPrice"] != null && row["totalPrice"].ToString() != "")
                {
                    model.totalPrice = decimal.Parse(row["totalPrice"].ToString());
                }
                if (row["averagePrice"] != null && row["averagePrice"].ToString() != "")
                {
                    model.averagePrice = decimal.Parse(row["averagePrice"].ToString());
                }
                if (row["sellPrice"] != null && row["sellPrice"].ToString() != "")
                {
                    model.sellPrice = decimal.Parse(row["sellPrice"].ToString());
                }
                if (row["isArrive"] != null && row["isArrive"].ToString() != "")
                {
                    model.isArrive = int.Parse(row["isArrive"].ToString());
                }
            }
            return(model);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(t_procurement_records model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_procurement_records set ");
            strSql.Append("goodsName=@goodsName,");
            strSql.Append("kind=@kind,");
            strSql.Append("buyTime=@buyTime,");
            strSql.Append("buyCount=@buyCount,");
            strSql.Append("buyPrice=@buyPrice,");
            strSql.Append("freight=@freight,");
            strSql.Append("otherMoney=@otherMoney,");
            strSql.Append("totalPrice=@totalPrice,");
            strSql.Append("averagePrice=@averagePrice,");
            strSql.Append("sellPrice=@sellPrice,");
            strSql.Append("isArrive=@isArrive");
            strSql.Append(" where id=@id ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@goodsName",    MySqlDbType.VarChar,   255),
                new MySqlParameter("@kind",         MySqlDbType.VarChar,   255),
                new MySqlParameter("@buyTime",      MySqlDbType.DateTime),
                new MySqlParameter("@buyCount",     MySqlDbType.Int32,      11),
                new MySqlParameter("@buyPrice",     MySqlDbType.Decimal,    10),
                new MySqlParameter("@freight",      MySqlDbType.Decimal,    10),
                new MySqlParameter("@otherMoney",   MySqlDbType.Decimal,    10),
                new MySqlParameter("@totalPrice",   MySqlDbType.Decimal,    10),
                new MySqlParameter("@averagePrice", MySqlDbType.Decimal,    10),
                new MySqlParameter("@sellPrice",    MySqlDbType.Decimal,    10),
                new MySqlParameter("@isArrive",     MySqlDbType.Int32,      11),
                new MySqlParameter("@id",           MySqlDbType.Int32, 10)
            };
            parameters[0].Value  = model.goodsName;
            parameters[1].Value  = model.kind;
            parameters[2].Value  = model.buyTime;
            parameters[3].Value  = model.buyCount;
            parameters[4].Value  = model.buyPrice;
            parameters[5].Value  = model.freight;
            parameters[6].Value  = model.otherMoney;
            parameters[7].Value  = model.totalPrice;
            parameters[8].Value  = model.averagePrice;
            parameters[9].Value  = model.sellPrice;
            parameters[10].Value = model.isArrive;
            parameters[11].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(t_procurement_records model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_procurement_records(");
            strSql.Append("id,goodsName,kind,buyTime,buyCount,buyPrice,freight,otherMoney,totalPrice,averagePrice,sellPrice,isArrive)");
            strSql.Append(" values (");
            strSql.Append("@id,@goodsName,@kind,@buyTime,@buyCount,@buyPrice,@freight,@otherMoney,@totalPrice,@averagePrice,@sellPrice,@isArrive)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id",           MySqlDbType.Int32,      10),
                new MySqlParameter("@goodsName",    MySqlDbType.VarChar,   255),
                new MySqlParameter("@kind",         MySqlDbType.VarChar,   255),
                new MySqlParameter("@buyTime",      MySqlDbType.DateTime),
                new MySqlParameter("@buyCount",     MySqlDbType.Int32,      11),
                new MySqlParameter("@buyPrice",     MySqlDbType.Decimal,    10),
                new MySqlParameter("@freight",      MySqlDbType.Decimal,    10),
                new MySqlParameter("@otherMoney",   MySqlDbType.Decimal,    10),
                new MySqlParameter("@totalPrice",   MySqlDbType.Decimal,    10),
                new MySqlParameter("@averagePrice", MySqlDbType.Decimal,    10),
                new MySqlParameter("@sellPrice",    MySqlDbType.Decimal,    10),
                new MySqlParameter("@isArrive",     MySqlDbType.Int32, 11)
            };
            parameters[0].Value  = model.id;
            parameters[1].Value  = model.goodsName;
            parameters[2].Value  = model.kind;
            parameters[3].Value  = model.buyTime;
            parameters[4].Value  = model.buyCount;
            parameters[5].Value  = model.buyPrice;
            parameters[6].Value  = model.freight;
            parameters[7].Value  = model.otherMoney;
            parameters[8].Value  = model.totalPrice;
            parameters[9].Value  = model.averagePrice;
            parameters[10].Value = model.sellPrice;
            parameters[11].Value = model.isArrive;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public t_procurement_records GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,goodsName,kind,buyTime,buyCount,buyPrice,freight,otherMoney,totalPrice,averagePrice,sellPrice,isArrive from t_procurement_records ");
            strSql.Append(" where id=@id ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32, 10)
            };
            parameters[0].Value = id;

            t_procurement_records model = new t_procurement_records();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(t_procurement_records model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(t_procurement_records model)
 {
     return(dal.Add(model));
 }