Пример #1
0
        private void Remove_OnClick(object o, RoutedEventArgs e)
        {
            var p = venda.SelectedItem as vendaItem;

            if (produtos.SelectedItem != null)
            {
                if (p != null)
                {
                    int i = products.IndexOf(p);

                    if (p.getQtd() > 1)
                    {
                        var item = new vendaItem(p.getCodigo(), p.getNome(), p.getValor() - (p.getValor() / p.getQtd()),
                                                 p.getQtd() - 1);
                        products[i] = item;
                    }
                    else
                    {
                        products.RemoveAt(i);
                    }
                    valueBox.Text =
                        Convert.ToString((Convert.ToDouble(valueBox.Text.Split(' ')[0]) - (p.getValor() / p.getQtd())) + " €");
                    updateValorFinal((p.getValor() / p.getQtd()), 2);
                }
            }
        }
Пример #2
0
        private void Add_OnClick(object sender, RoutedEventArgs e)
        {
            if (produtos.SelectedItem != null)
            {
                DataRowView dataRow   = (DataRowView)produtos.SelectedItem;
                string      cellValue = dataRow.Row.ItemArray[1].ToString();
                int         pcode     = Convert.ToInt32(dataRow.Row.ItemArray[0]);
                double      ivalue    = Convert.ToDouble(dataRow.Row.ItemArray[2]);
                int         qtd;

                var p = products.FirstOrDefault(x => x.getNome() == cellValue);
                if (p != null)
                {
                    int i    = products.IndexOf(p);
                    var item = new vendaItem(pcode, cellValue, p.getValor() + ivalue, p.getQtd() + 1);
                    products[i] = item;
                }
                else
                {
                    var item = new vendaItem(pcode, cellValue, ivalue, 1);
                    products.Add(item);
                }

                venda.ItemsSource = products;
                valueBox.Text     = Convert.ToString((Convert.ToDouble(valueBox.Text.Split(' ')[0]) + ivalue) + " €");
                updateValorFinal(ivalue, 1);
            }
        }
Пример #3
0
        private void getProduct(int loja, int codigo)
        {
            Connection.Conn.Open();
            SqlCommand cmd = new SqlCommand("YourEntertainment.pr_GetProductByCode", Connection.Conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@loja", loja);
            cmd.Parameters.AddWithValue("@codigo", codigo);

            var returnName = cmd.Parameters.Add("@nome", SqlDbType.VarChar);

            returnName.Size      = 50;
            returnName.Direction = ParameterDirection.Output;
            var returnPrice = cmd.Parameters.Add("@preco", SqlDbType.Decimal);

            returnPrice.Direction = ParameterDirection.Output;
            var res = cmd.Parameters.Add("@res", SqlDbType.Bit);

            res.Direction = ParameterDirection.Output;

            cmd.ExecuteNonQuery();

            if (Convert.ToBoolean(res.Value) == false)
            {
                MessageBox.Show("Produto não encontrado");
                CodigoBox.Text = "";
            }
            else
            {
                var p = products.FirstOrDefault(x => x.getNome().Equals(returnName.Value));
                if (p != null)
                {
                    int i    = products.IndexOf(p);
                    var item = new vendaItem(codigo, returnName.Value.ToString(), p.getValor() + Convert.ToDouble(returnPrice.Value), p.getQtd() + 1);
                    products[i] = item;
                }
                else
                {
                    var item = new vendaItem(codigo, returnName.Value.ToString(), Convert.ToDouble(returnPrice.Value), 1);
                    products.Add(item);
                }

                venda.ItemsSource = products;
                valueBox.Text     = Convert.ToString((Convert.ToDouble(valueBox.Text.Split(' ')[0]) + Convert.ToDouble(returnPrice.Value)) + " €");
                updateValorFinal(Convert.ToDouble(returnPrice.Value), 1);
            }
            Connection.Conn.Close();
        }
Пример #4
0
        private void getProduct(int loja, int codigo)
        {

            Connection.Conn.Open();
            SqlCommand cmd = new SqlCommand("YourEntertainment.pr_GetProductByCode", Connection.Conn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@loja", loja);
            cmd.Parameters.AddWithValue("@codigo", codigo);

            var returnName = cmd.Parameters.Add("@nome", SqlDbType.VarChar);
            returnName.Size = 50;
            returnName.Direction = ParameterDirection.Output;
            var returnPrice = cmd.Parameters.Add("@preco", SqlDbType.Decimal);
            returnPrice.Direction = ParameterDirection.Output;
            var res = cmd.Parameters.Add("@res", SqlDbType.Bit);
            res.Direction = ParameterDirection.Output;

            cmd.ExecuteNonQuery();

            if ( Convert.ToBoolean(res.Value) == false)
            {
                MessageBox.Show("Produto não encontrado");
                CodigoBox.Text = "";
            }
            else
            {
                var p = products.FirstOrDefault(x => x.getNome().Equals(returnName.Value));
                if (p != null)
                {
                    int i = products.IndexOf(p);
                    var item = new vendaItem(codigo, returnName.Value.ToString(), p.getValor() + Convert.ToDouble(returnPrice.Value), p.getQtd() + 1);
                    products[i] = item;
                }
                else
                {
                    var item = new vendaItem(codigo,returnName.Value.ToString() , Convert.ToDouble(returnPrice.Value), 1);
                    products.Add(item);
                }

                venda.ItemsSource = products;
                valueBox.Text = Convert.ToString((Convert.ToDouble(valueBox.Text.Split(' ')[0]) + Convert.ToDouble(returnPrice.Value)) + " €");
                updateValorFinal(Convert.ToDouble(returnPrice.Value),1);
            }
            Connection.Conn.Close();

        }
Пример #5
0
        private void Remove_OnClick(object o, RoutedEventArgs e)
        {
            var p = venda.SelectedItem as vendaItem;
            if (produtos.SelectedItem != null)
            {
                if (p != null)
                {
                    int i = products.IndexOf(p);

                    if (p.getQtd() > 1)
                    {
                        var item = new vendaItem(p.getCodigo(), p.getNome(), p.getValor() - (p.getValor()/p.getQtd()),
                            p.getQtd() - 1);
                        products[i] = item;
                    }
                    else
                    {
                        products.RemoveAt(i);
                    }
                    valueBox.Text =
                        Convert.ToString((Convert.ToDouble(valueBox.Text.Split(' ')[0]) - (p.getValor()/p.getQtd())) +" €");
                    updateValorFinal((p.getValor()/p.getQtd()), 2);
                }
            }

        }
Пример #6
0
        private void Add_OnClick(object sender, RoutedEventArgs e)
        {
            if(produtos.SelectedItem != null)
            {
                DataRowView dataRow = (DataRowView) produtos.SelectedItem;
                string cellValue = dataRow.Row.ItemArray[1].ToString();
                int pcode = Convert.ToInt32(dataRow.Row.ItemArray[0]);
                double ivalue = Convert.ToDouble(dataRow.Row.ItemArray[2]);
                int qtd;

                var p = products.FirstOrDefault(x => x.getNome() == cellValue);
                if (p != null)
                {
                    int i = products.IndexOf(p);
                    var item = new vendaItem(pcode, cellValue, p.getValor() + ivalue, p.getQtd() + 1);
                    products[i] = item;
                }
                else
                {
                    var item = new vendaItem(pcode, cellValue, ivalue, 1);
                    products.Add(item);
                }

                venda.ItemsSource = products;
                valueBox.Text = Convert.ToString((Convert.ToDouble(valueBox.Text.Split(' ')[0]) + ivalue) + " €");
                updateValorFinal(ivalue,1);
                
            }
        }