示例#1
0
        public int CreateGoods(Goods g)
        {
            int ret = 0;
            using (connect = new MySqlConnection(_connectionString))
            {
                connect.Open();
                using (MySqlTransaction transaction = connect.BeginTransaction())
                {
                    try
                    {
                        string query = "NewGoods";
                        var cmd = new MySqlCommand(query, connect) { CommandType = CommandType.StoredProcedure };

                        cmd.Parameters.AddWithValue("ItemName", g.Name);
                        cmd.Parameters.AddWithValue("HandlingRequirements", g.Name);

                        ret = int.Parse(cmd.ExecuteScalar().ToString());

                        transaction.Commit();

                        connect.Close();
                    }
                    catch (InvalidOperationException ioException)
                    {
                        transaction.Rollback();
                        connect.Close();
                    }
                }
            }
            return ret;
        }
示例#2
0
        // Create goods
        public int create(String name, String handling)
        {
            // Establishes model
            GoodsModel goodsModel = new GoodsModel();

            // Holds the new goods
            Goods newGoods = new Goods();

            // Stored details for the goods
            newGoods.Name = name;
            newGoods.HandlingRequirments = handling;

            // Adds the object to the database
            int goodsID = goodsModel.CreateGoods(newGoods);

            // Return goodsID
            return goodsID;
        }
示例#3
0
 // This method is to get order that match on elements included in the goods object.
 public List<Order> SearchOrder(Goods g)
 {
     throw new NotImplementedException();
 }
示例#4
0
 // This method is to get packages that match on elements included in the goods object.
 public List<Package> SearchPackage(Goods g)
 {
     throw new NotImplementedException();
 }
示例#5
0
        public void EditGoods(Goods g)
        {
            using (connect = new MySqlConnection(_connectionString))
            {
                connect.Open();
                using (MySqlTransaction transaction = connect.BeginTransaction())
                {
                    try
                    {
                        string query = "EditGoods";
                        var cmd = new MySqlCommand(query, connect) { CommandType = CommandType.StoredProcedure };

                        cmd.Parameters.AddWithValue("GoodsID", g.ID);
                        cmd.Parameters.AddWithValue("HandlingRequirements", g.HandlingRequirments);

                        cmd.ExecuteNonQuery();

                        transaction.Commit();

                        connect.Close();
                    }
                    catch (InvalidOperationException ioException)
                    {
                        transaction.Rollback();
                        connect.Close();
                    }
                }
            }
        }
示例#6
0
 public Goods SearchGoodst(Goods a)
 {
     return SearchGoods(a.ID);
 }
示例#7
0
        // The main method to get a user account.
        public Goods SearchGoods(int ID)
        {
            var goods = new Goods();

            using (connect = new MySqlConnection(_connectionString))
            {
                try
                {
                    string query = "GetGoods";
                    var cmd = new MySqlCommand(query, connect) { CommandType = CommandType.StoredProcedure };

                    connect.Open();

                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        goods.ID = int.Parse(reader["Goods_ID"].ToString());
                        goods.Name = reader["Item_Name"].ToString();
                        goods.HandlingRequirments = reader["Handling_requirements"].ToString();

                    }

                    connect.Close();
                }
                catch (InvalidOperationException ioException)
                {
                    connect.Close();
                }

                return goods;
            }
        }