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
        private void CmbItemCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            /*ItemDTO item = new ItemDTO();
             * item = ItemController.searchItem((cmbItemCode.SelectedItem).ToString());
             * txtItemDescription.Text = item.getItemName();
             * txtQtyOnHand.Text = (item.getQuantity()).ToString();
             * txtUnitPrice.Text = (item.getPrice()).ToString();
             * codeOfItem = item.getItemCode();*/
            ItemDTO item = new ItemDTO();

            item              = ItemController.searchItemDescription((cmbItemDescription.SelectedItem).ToString());
            txtItemCode.Text  = item.getItemCode();
            txtQtyOnHand.Text = (item.getQuantity()).ToString();
            txtUnitPrice.Text = (item.getPrice()).ToString();
            codeOfItem        = item.getItemCode();
        }
Exemplo n.º 3
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);
            }
        }