Beispiel #1
0
        // Método que inserta una compra

        private void btInsertBuy_Click(object sender, EventArgs e)
        {
            bool isValid = ValidateField();

            if (isValid)
            {
                BuyTicket buyTicket = new BuyTicket()
                {
                    Amount        = Convert.ToDecimal(this.txtInsertAmount.Text),
                    Price         = Convert.ToDecimal(this.txtInsertTotal.Text),
                    BuyTicketDate = DateTime.Parse(this.dtDateIn.Text),
                    BuyTicketId   = Guid.NewGuid(),
                    Products      = _products,
                    SupplierId    = new Guid(this.SupplierId.Text),
                    UserId        = new Guid(this.UserId.Text)
                };

                bool hasBeenInserted = BussinesBuy.InsertTicket(buyTicket);

                if (hasBeenInserted)
                {
                    CleanFieldsInserted();
                    MessageBox.Show("Compra insertada correctamente");
                    this.dtBuyTickets.DataSource = BussinesBuy.GetAllBuyTickets().ToList();
                }
                else
                {
                    MessageBox.Show("Error al insertar compra");
                }
            }
        }
Beispiel #2
0
        // Botón para eliminar una compra

        private void button3_Click(object sender, EventArgs e)
        {
            var rows = this.dtBuyTickets.CurrentRow;

            if (rows != null)
            {
                var isDeleted = BussinesBuy.DeleteBuyTicket(new Guid(rows.Cells["BuyTicketId"].Value.ToString()));

                if (isDeleted)
                {
                    this.dtBuyTickets.DataSource = BussinesBuy.GetAllBuyTickets().ToList();
                    MessageBox.Show("Compra borrada correctamente");
                }
                else
                {
                    MessageBox.Show("Error borrando compra");
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar una fila que borrar");
            }
        }
Beispiel #3
0
 private void Buys_Load(object sender, EventArgs e)
 {
     this.dtBuyTickets.DataSource = BussinesBuy.GetAllBuyTickets().ToList();
 }