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); } }
private async void btnRegisterPurchase_Click(object sender, EventArgs e) { try { if (this.txtRuc.Text == string.Empty) { throw new ArgumentNullException("Debe ingresar el RUC del proveedor."); } if (this.txtRuc.TextLength != 11) { throw new ArgumentException("El RUC debe tener exacntamente 11 digitos"); } if (this.cartDetailPurchase.getCount() == 0) { throw new ArgumentException("Debe registrar como minimo 1 producto para realizar la COMPRA"); } Purchase purchase = new Purchase { ruc = this.txtRuc.Text, detailPurchaseList = this.cartDetailPurchase.ToDetailPurchaseList(), total = this.cartDetailPurchase.total }; Purchase resultPurchase = await PurchaseService.RegisterPurchase(purchase); FormSuccess.ConfirmationForm("REGISTRADO"); this.ResetRegisterConfiguration(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnUpdateDS_Click(object sender, EventArgs e) { try { if (this.dgvCart.SelectedRows.Count > 1) { throw new ArgumentException("Debe seleccionar solo una fila para editar."); } if (this.dgvCart.SelectedRows.Count == 0) { throw new ArgumentException("Debe seleccionar una fila para editar."); } int index = this.dgvCart.CurrentRow.Index; DialogResult result = new DialogResult(); FormModifySaleCount frmModifySaleCount = new FormModifySaleCount( "Ingrese la cantidad", this.cartDetailSale.GetByIndex(index)); result = frmModifySaleCount.ShowDialog(this); if (result == DialogResult.OK) { this.cartDetailSale.UpdateSaleCountByIndex(index, frmModifySaleCount.value); this.sourceList.ResetItem(index); this.UpdateTotalAndSimilars(Convert.ToDecimal(this.cartDetailSale.total)); FormSuccess.ConfirmationForm("MODIFICADO"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnAddTo_Click(object sender, EventArgs e) { try { if (dgvProductDetails.SelectedRows.Count == 0) { throw new Exception("Seleccione un producto para agregar al carrito"); } foreach (DataGridViewRow detailProduct in this.dgvProductDetails.SelectedRows) { if (this.formParent == FormTypes.FormRegisterSales) { this.cartDetailSale.AddCartItem(new CartDetailSaleItem(currentProductSelected, detailProduct.DataBoundItem as DetailProduct)); } else if (this.formParent == FormTypes.FormRegisterPurchase) { this.cartDetailPurchase.AddCartDPItem(new CartDetailPurchaseItem(currentProductSelected, detailProduct.DataBoundItem as DetailProduct)); } } FormSuccess.ConfirmationForm("AGREGADO"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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); } }
private void btnUpdateDPu_Click(object sender, EventArgs e) { try { if (this.dgvDPurchase.SelectedRows.Count > 1) { throw new ArgumentException("Debe seleccionar solo una fila para editar."); } if (this.dgvDPurchase.SelectedRows.Count == 0) { throw new ArgumentException("Debe seleccionar una fila para editar."); } int index = this.dgvDPurchase.CurrentRow.Index; DialogResult result = new DialogResult(); FormUpdateCartDetailPurchaseItem formUpdateCartDetailPurchaseItem = new FormUpdateCartDetailPurchaseItem( "Modificar Registro", this.cartDetailPurchase.GetByIndex(index).quantity, this.cartDetailPurchase.GetByIndex(index).unitPrice); result = formUpdateCartDetailPurchaseItem.ShowDialog(this); if (result == DialogResult.OK) { this.cartDetailPurchase.UpdateQuantityByIndex(index, formUpdateCartDetailPurchaseItem.quantity); this.cartDetailPurchase.UpdateUnitPriceByIndex(index, formUpdateCartDetailPurchaseItem.unitPrice); this.sourceList.ResetItem(index); this.UpdateTotalAndSimilars(Convert.ToDecimal(this.cartDetailPurchase.total)); FormSuccess.ConfirmationForm("MODIFICADO"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }