Exemplo n.º 1
0
        public static Boolean updateItem(ItemDTO itemDTO)
        {
            int result = 0;

            try
            {
                string query = "update pos.item SET itemname=@itemname, price=@price,quantity=@quantity where itemcode=@itemcode";

                MySqlCommand command = new MySqlCommand(query, conn);
                command.Parameters.AddWithValue("@itemname", itemDTO.getItemName());
                command.Parameters.AddWithValue("@price", itemDTO.getPrice());
                command.Parameters.AddWithValue("@quantity", itemDTO.getPrice());
                command.Parameters.AddWithValue("@itemcode", itemDTO.getItemCode());
                conn.Open();

                result = command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                conn.Close();
                return(false);
            }

            Console.Read();
            conn.Close();
            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public static Boolean addNewItem(ItemDTO itemDTO)
        {
            int result = 0;

            try
            {
                String query = "INSERT INTO pos.item (itemcode,itemname,quantity,price) VALUES (@itemcode, @itemname, @quantity,@price)";

                MySqlCommand command = new MySqlCommand(query, conn);

                //Console.WriteLine(custDTO.getNic() + " " + custDTO.getName());

                command.Parameters.AddWithValue("@itemcode", itemDTO.getItemCode());
                command.Parameters.AddWithValue("@itemname", itemDTO.getItemName());
                command.Parameters.AddWithValue("@quantity", itemDTO.getQuantity());
                command.Parameters.AddWithValue("@price", itemDTO.getPrice());

                conn.Open();

                result = command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                // MessageBox.Show("exception occured");
                conn.Close();
                return(false);
            }

            Console.Read();
            conn.Close();
            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }