Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(FishEntity.FoodOutDetailEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_foodoutdetail(");
            strSql.Append("mid,productid,tons,package,unitprice,cost,no,solutionid)");
            strSql.Append(" values (");
            strSql.Append("@mid,@productid,@tons,@package,@unitprice,@cost,@no,@solutionid);");
            strSql.Append("select LAST_INSERT_ID();");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@mid",        MySqlDbType.Int32,   11),
                new MySqlParameter("@productid",  MySqlDbType.Int32,    8),
                new MySqlParameter("@tons",       MySqlDbType.Decimal, 12),
                new MySqlParameter("@package",    MySqlDbType.Int32,    8),
                new MySqlParameter("@unitprice",  MySqlDbType.Decimal, 12),
                new MySqlParameter("@cost",       MySqlDbType.Decimal, 12),
                new MySqlParameter("@no",         MySqlDbType.Int32,    6),
                new MySqlParameter("@solutionid", MySqlDbType.Int32, 6)
            };
            parameters[0].Value = model.mid;
            parameters[1].Value = model.productid;
            parameters[2].Value = model.tons;
            parameters[3].Value = model.package;
            parameters[4].Value = model.unitprice;
            parameters[5].Value = model.cost;
            parameters[6].Value = model.no;
            parameters[7].Value = model.solutionid;

            int id = MySqlHelper.ExecuteSqlReturnId(strSql.ToString(), parameters);

            return(id);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(FishEntity.FoodOutDetailEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_foodoutdetail set ");
            strSql.Append("mid=@mid,");
            strSql.Append("productid=@productid,");
            strSql.Append("tons=@tons,");
            strSql.Append("package=@package,");
            strSql.Append("unitprice=@unitprice,");
            strSql.Append("cost=@cost,");
            strSql.Append("no=@no,");
            strSql.Append("solutionid=@solutionid");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@mid",        MySqlDbType.Int32,   11),
                new MySqlParameter("@productid",  MySqlDbType.Int32,    8),
                new MySqlParameter("@tons",       MySqlDbType.Decimal, 12),
                new MySqlParameter("@package",    MySqlDbType.Int32,    8),
                new MySqlParameter("@unitprice",  MySqlDbType.Decimal, 12),
                new MySqlParameter("@cost",       MySqlDbType.Decimal, 12),
                new MySqlParameter("@no",         MySqlDbType.Int32,    6),
                new MySqlParameter("@solutionid", MySqlDbType.Int32,    6),
                new MySqlParameter("@id",         MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.mid;
            parameters[1].Value = model.productid;
            parameters[2].Value = model.tons;
            parameters[3].Value = model.package;
            parameters[4].Value = model.unitprice;
            parameters[5].Value = model.cost;
            parameters[6].Value = model.no;
            parameters[7].Value = model.solutionid;
            parameters[8].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public FishEntity.FoodOutDetailEntity DataRowToModel(DataRow row)
 {
     FishEntity.FoodOutDetailEntity model = new FishEntity.FoodOutDetailEntity();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["mid"] != null && row["mid"].ToString() != "")
         {
             model.mid = int.Parse(row["mid"].ToString());
         }
         if (row["productid"] != null && row["productid"].ToString() != "")
         {
             model.productid = int.Parse(row["productid"].ToString());
         }
         if (row["tons"] != null && row["tons"].ToString() != "")
         {
             model.tons = decimal.Parse(row["tons"].ToString());
         }
         if (row["package"] != null && row["package"].ToString() != "")
         {
             model.package = int.Parse(row["package"].ToString());
         }
         if (row["unitprice"] != null && row["unitprice"].ToString() != "")
         {
             model.unitprice = decimal.Parse(row["unitprice"].ToString());
         }
         if (row["cost"] != null && row["cost"].ToString() != "")
         {
             model.cost = decimal.Parse(row["cost"].ToString());
         }
         if (row["no"] != null && row["no"].ToString() != "")
         {
             model.no = int.Parse(row["no"].ToString());
         }
         if (row["solutionid"] != null && row["solutionid"].ToString() != "")
         {
             model.solutionid = int.Parse(row["solutionid"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FishEntity.FoodOutDetailEntity GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,mid,productid,tons,package,unitprice,cost,no,solutionid from t_foodoutdetail ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

            FishEntity.FoodOutDetailEntity model = new FishEntity.FoodOutDetailEntity();
            DataSet ds = MySqlHelper.Query(strSql.ToString(), parameters);

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