private void btnDeleteDPu_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.dgvDPurchase.SelectedRows.Count == 0)
                {
                    throw new ArgumentException("Debe seleccionar una fila para eliminar.");
                }

                DialogResult    result          = new DialogResult();
                FormInformation formInformation = new FormInformation("¿ESTAS SEGURO DE ELIMINAR EL REGISTRO?");
                result = formInformation.ShowDialog();
                if (result == DialogResult.OK)
                {
                    CartDetailPurchase detailProduct = this.dgvDPurchase.CurrentRow.DataBoundItem as CartDetailPurchase;
                    int index = this.dgvDPurchase.CurrentRow.Index;
                    this.cartDetailPurchase.DeleteCartDetailPurchaseItem(index);
                    this.sourceList.ResetBindings();
                    this.UpdateTotalAndSimilars(Convert.ToDecimal(this.cartDetailPurchase.total));

                    FormSuccess.ConfirmationForm("ELIMINADO");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        private async void dgvSales_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (this.dgvSales.Rows[e.RowIndex].Cells["DetailSale"].Selected)
                {
                    this.PaintRowAndUnpaintLastSelectedRow(e.RowIndex);

                    long idSale = (long)this.dgvSales.Rows[e.RowIndex].Cells["idSale"].Value;
                    this.dgvDetailsSale.DataSource = await DetailSaleService.ListDetailSaleLikeCartItemByIdSale(idSale);
                }
                else if (this.dgvSales.Rows[e.RowIndex].Cells["PDFView"].Selected)
                {
                    this.PaintRowAndUnpaintLastSelectedRow(e.RowIndex);

                    long idSale = (long)this.dgvSales.Rows[e.RowIndex].Cells["idSale"].Value;
                    SaleService.ExportInPDFDetailSaleLikeCartItemByIdSale(idSale);
                }
                else if (this.dgvSales.Rows[e.RowIndex].Cells["cancelSale"].Selected)
                {
                    this.PaintRowAndUnpaintLastSelectedRow(e.RowIndex);

                    DialogResult    result          = new DialogResult();
                    FormInformation formInformation = new FormInformation("¿ESTAS SEGURO DE ANULAR LA VENTA?");
                    result = formInformation.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        long idSale = (long)this.dgvSales.Rows[e.RowIndex].Cells["idSale"].Value;
                        if (await SaleService.CancelSaleByIdSale(idSale))
                        {
                            FormSuccess.ConfirmationForm("ANULADO");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }