private void Btn_Pagar_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(Txt_Monto_Pagar.Text) || String.IsNullOrEmpty(Txt_Nombre_Tarjeta.Text) || String.IsNullOrEmpty(Txt_Numero_Tarjeta.Text) || String.IsNullOrEmpty(Txt_Codigo_Seguridad.Text)) { MessageBox.Show("Algunos campos aún se encuentran vacíos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (Dtp_Fecha_Expiraciom.Value.Date.Day == DateTime.Today.Date.Day) { MessageBox.Show("La tarjeta que está tratando de ingresar ya expiró", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (MessageBox.Show("¿Desea continuar con el proceso de facturació?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { bl.FacturarPago(Bill_Type, Payment_Type, Subtotal, Subtotal_Discount, Total_Taxes, Total, ID_Client, ID_Discount); bl.Ligar_DetalleFactura_Factura(bl.ObtenerUltimoNumero() - 1); bl.Insertar_CierreCajas_Facturacion(DateTime.Today, Bill_Type, Payment_Type, Total, bl.ObtenerUltimoNumero() - 1); MessageBox.Show("Se han facturado los productos de manera exitosa", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); // Se cierra la pantalla apenas de concrete el pago. this.Dispose(); Form_Facturación WindowsView = new Form_Facturación(bl); WindowsView.Show(); } }
private void button1_Click(object sender, EventArgs e) { this.Dispose(); Form_Facturación fm = new Form_Facturación(bl); fm.Show(); }
private void Btn_Salir_Click(object sender, EventArgs e) { if (MessageBox.Show("¿Está seguro que desea salir? La factura se anulará", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.Dispose(); Form_Facturación WindowsView = new Form_Facturación(bl); WindowsView.Show(); } }
private void Btn_Salir_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(Txt_Monto_Cliente.Text) || String.IsNullOrEmpty(Txt_Vuelto.Text)) { if (MessageBox.Show("¿Está seguro que desea salir? No se guardarán los cambios y se anulará el detalle de factura", "Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { // Aquí se debe anular el detalle de factura. this.Close(); Form_Facturación WindowView = new Form_Facturación(bl); WindowView.Show(); } } else { this.Close(); Form_Facturación WindowView = new Form_Facturación(bl); WindowView.Show(); } }
private void Btn_Facturar_Click(object sender, EventArgs e) { if (Convert.ToDecimal(Lbl_Total.Text) < 0 || Convert.ToDecimal(Lbl_Total.Text) == 0) { MessageBox.Show("El monto total que está tratando de facturar no es válido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int CantidadProductoTotal = SumarProductos(); if (Cmb_Tipo_Venta.SelectedItem.ToString() == "Contado" && Cmb_Tipo_Pago.SelectedItem.ToString() == "Efectivo") { label7.Text = DateTime.Now.ToString(); label9.Text = ""; bl.GetTotal(decimal.Parse(Lbl_Total.Text)); if (lbl_Tipo_Cliente.Text == "VIP") { if (Lbl_Descuento.Text == "N/A") { Lbl_Descuento.Text = "0"; Lbl_SubTotalDescuento.Text = "0"; Form_Pagar fp = new Form_Pagar(bl, Cmb_Tipo_Venta.SelectedItem.ToString(), Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_SubTotal.Text), 0, Convert.ToDecimal(Lbl_Impuestos.Text), Convert.ToDecimal(Lbl_Total.Text), bl.ClienteExiste(Txt_Identificacion.Text).Id_cliente, 0); this.Dispose(); fp.Show(); } else { Form_Pagar fp = new Form_Pagar(bl, Cmb_Tipo_Venta.SelectedItem.ToString(), Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_SubTotal.Text), Convert.ToDecimal(Lbl_SubTotalDescuento.Text), Convert.ToDecimal(Lbl_Impuestos.Text), Convert.ToDecimal(Lbl_Total.Text), bl.ClienteExiste(Txt_Identificacion.Text).Id_cliente, bl.Descuento_Aplicado_VIP(Convert.ToInt32(Txt_Puntos.Text)).Id_DescVIP); this.Dispose(); fp.Show(); } } else { if (Lbl_Descuento.Text == "N/A") { Lbl_Descuento.Text = "0"; Lbl_SubTotalDescuento.Text = "0"; Form_Pagar fp = new Form_Pagar(bl, Cmb_Tipo_Venta.SelectedItem.ToString(), Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_SubTotal.Text), Convert.ToDecimal(Lbl_SubTotalDescuento.Text), Convert.ToDecimal(Lbl_Impuestos.Text), Convert.ToDecimal(Lbl_Total.Text), bl.ClienteExiste(Txt_Identificacion.Text).Id_cliente, 0); this.Dispose(); fp.Show(); } else { Form_Pagar fp = new Form_Pagar(bl, Cmb_Tipo_Venta.SelectedItem.ToString(), Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_SubTotal.Text), Convert.ToDecimal(Lbl_SubTotalDescuento.Text), Convert.ToDecimal(Lbl_Impuestos.Text), Convert.ToDecimal(Lbl_Total.Text), bl.ClienteExiste(Txt_Identificacion.Text).Id_cliente, bl.Descuento_Aplicado(CantidadProductoTotal, DateTime.Today.DayOfWeek.ToString()).Id_DescEstandar); this.Dispose(); fp.Show(); } } for (int i = Dgv_Detalle_Factura.Rows.Count - 1; i > -1; i--) { DataGridViewRow row = Dgv_Detalle_Factura.Rows[i]; if (!row.IsNewRow && row.Cells[0].Value == null) { Dgv_Detalle_Factura.Rows.RemoveAt(i); } } for (int i = 0; i < Dgv_Detalle_Factura.RowCount; i++) { if (Dgv_Detalle_Factura.Rows[i].Cells[0].Value != null) { Descripcion_Producto = Dgv_Detalle_Factura.Rows[i].Cells[1].Value.ToString(); Codigo_Producto = Dgv_Detalle_Factura.Rows[i].Cells[2].Value.ToString(); Precio_Unitario = Dgv_Detalle_Factura.Rows[i].Cells[3].Value.ToString(); Cantidad = Dgv_Detalle_Factura.Rows[i].Cells[4].Value.ToString(); bl.AgregarProducto_DetalleFactura(Descripcion_Producto, Codigo_Producto, Convert.ToDecimal(Precio_Unitario), Convert.ToInt32(Cantidad)); } else { break; } } } if (Cmb_Tipo_Venta.SelectedItem.ToString() == "Crédito") { if (MessageBox.Show("¿Está seguro que desea generar una factura a crédito?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (Lbl_Descuento.Text == "N/A" && lbl_Tipo_Cliente.Text == "VIP") { Lbl_Descuento.Text = "0"; Lbl_SubTotalDescuento.Text = "0"; label7.Text = DateTime.Now.ToString(); label9.Text = DateTime.Now.AddDays(+15).ToString(); bl.FacturarPago("Crédito", Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_SubTotal.Text), Convert.ToDecimal(Lbl_SubTotalDescuento.Text), Convert.ToDecimal(Lbl_Descuento.Text), Convert.ToDecimal(Lbl_Total.Text), bl.BuscarCliente(Txt_Identificacion.Text, tipoId).Id_cliente, 0); bl.Insertar_CierreCajas_Facturacion(DateTime.Now, "Crédito", Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_Total.Text), Convert.ToInt32(Lbl_NumeroFactura.Text)); bl.Ligar_DetalleFactura_Factura(bl.ObtenerUltimoNumero() - 1); bl.Insertar_CuentaCobrar_Facturacion(DateTime.Today.Date, Txt_Identificacion.Text, lbl_Nombre_Cliente.Text, 0, Convert.ToDecimal(Lbl_Total.Text), Convert.ToInt32(Lbl_NumeroFactura.Text)); MessageBox.Show("El proceso de facturación se ha concretado exitosamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); Form_Facturación fpt = new Form_Facturación(bl); this.Dispose(); fpt.Show(); } else if (Convert.ToDecimal(Lbl_Descuento.Text) > 0 && lbl_Tipo_Cliente.Text == "VIP") { label7.Text = DateTime.Now.ToString(); label9.Text = DateTime.Now.AddDays(+15).ToString(); bl.FacturarPago("Crédito", Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_SubTotal.Text), Convert.ToDecimal(Lbl_SubTotalDescuento.Text), Convert.ToDecimal(Lbl_Descuento.Text), Convert.ToDecimal(Lbl_Total.Text), bl.BuscarCliente(Txt_Identificacion.Text, tipoId).Id_cliente, bl.Descuento_Aplicado_VIP(Convert.ToInt32(Txt_Puntos.Text)).Id_DescVIP); bl.Insertar_CierreCajas_Facturacion(DateTime.Now, "Crédito", Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_Total.Text), Convert.ToInt32(Lbl_NumeroFactura.Text)); bl.Ligar_DetalleFactura_Factura(bl.ObtenerUltimoNumero() - 1); bl.Insertar_CuentaCobrar_Facturacion(DateTime.Today.Date, Txt_Identificacion.Text, lbl_Nombre_Cliente.Text, 0, Convert.ToDecimal(Lbl_Total.Text), Convert.ToInt32(Lbl_NumeroFactura.Text)); MessageBox.Show("El proceso de facturación se ha concretado exitosamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); Form_Facturación fpt = new Form_Facturación(bl); this.Dispose(); fpt.Show(); } if (Lbl_Descuento.Text == "N/A" && lbl_Tipo_Cliente.Text == "Estandar") { Lbl_Descuento.Text = "0"; Lbl_SubTotalDescuento.Text = "0"; label7.Text = DateTime.Now.ToString(); label9.Text = DateTime.Now.AddDays(+15).ToString(); bl.FacturarPago("Crédito", Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_SubTotal.Text), Convert.ToDecimal(Lbl_SubTotalDescuento.Text), Convert.ToDecimal(Lbl_Descuento.Text), Convert.ToDecimal(Lbl_Total.Text), bl.BuscarCliente(Txt_Identificacion.Text, tipoId).Id_cliente, 0); bl.Insertar_CierreCajas_Facturacion(DateTime.Now, "Crédito", Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_Total.Text), Convert.ToInt32(Lbl_NumeroFactura.Text)); bl.Ligar_DetalleFactura_Factura(bl.ObtenerUltimoNumero() - 1); bl.Insertar_CuentaCobrar_Facturacion(DateTime.Today.Date, Txt_Identificacion.Text, lbl_Nombre_Cliente.Text, 0, Convert.ToDecimal(Lbl_Total.Text), Convert.ToInt32(Lbl_NumeroFactura.Text)); MessageBox.Show("El proceso de facturación se ha concretado exitosamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); Form_Facturación fpt = new Form_Facturación(bl); this.Dispose(); fpt.Show(); } else if (Convert.ToDecimal(Lbl_Descuento.Text) > 0 && lbl_Tipo_Cliente.Text == "Estandar") { label7.Text = DateTime.Now.ToString(); label9.Text = DateTime.Now.AddDays(+15).ToString(); bl.FacturarPago("Crédito", Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_SubTotal.Text), Convert.ToDecimal(Lbl_SubTotalDescuento.Text), Convert.ToDecimal(Lbl_Descuento.Text), Convert.ToDecimal(Lbl_Total.Text), bl.BuscarCliente(Txt_Identificacion.Text, tipoId).Id_cliente, bl.Descuento_Aplicado(CantidadProductoTotal, DateTime.Today.DayOfWeek.ToString()).Id_DescEstandar); bl.Insertar_CierreCajas_Facturacion(DateTime.Now, "Crédito", Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_Total.Text), Convert.ToInt32(Lbl_NumeroFactura.Text)); bl.Ligar_DetalleFactura_Factura(bl.ObtenerUltimoNumero() - 1); bl.Insertar_CuentaCobrar_Facturacion(DateTime.Today.Date, Txt_Identificacion.Text, lbl_Nombre_Cliente.Text, 0, Convert.ToDecimal(Lbl_Total.Text), Convert.ToInt32(Lbl_NumeroFactura.Text)); MessageBox.Show("El proceso de facturación se ha concretado exitosamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); Form_Facturación fpt = new Form_Facturación(bl); this.Dispose(); fpt.Show(); } } else { return; } } if (Cmb_Tipo_Venta.SelectedItem.ToString() == "Contado" && Cmb_Tipo_Pago.SelectedItem.ToString() == "Tarjeta") { label7.Text = DateTime.Now.ToString(); label9.Text = ""; CantidadProductoTotal = SumarProductos(); label7.Text = DateTime.Now.ToString(); label9.Text = ""; bl.GetTotal(decimal.Parse(Lbl_Total.Text)); if (lbl_Tipo_Cliente.Text == "VIP") { if (Lbl_Descuento.Text == "N/A") { Form_Pagar_Tarjeta fpt = new Form_Pagar_Tarjeta(bl, Cmb_Tipo_Venta.SelectedItem.ToString(), Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_SubTotal.Text), Convert.ToDecimal(Lbl_SubTotalDescuento.Text), Convert.ToDecimal(Lbl_Impuestos.Text), Convert.ToDecimal(Lbl_Total.Text), bl.ClienteExiste(Txt_Identificacion.Text).Id_cliente, 0); this.Dispose(); fpt.Show(); } else { Form_Pagar_Tarjeta fpt = new Form_Pagar_Tarjeta(bl, Cmb_Tipo_Venta.SelectedItem.ToString(), Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_SubTotal.Text), Convert.ToDecimal(Lbl_SubTotalDescuento.Text), Convert.ToDecimal(Lbl_Impuestos.Text), Convert.ToDecimal(Lbl_Total.Text), bl.ClienteExiste(Txt_Identificacion.Text).Id_cliente, bl.Descuento_Aplicado_VIP(Convert.ToInt32(Txt_Puntos.Text)).Id_DescVIP); this.Dispose(); fpt.Show(); } } else { if (Lbl_Descuento.Text == "N/A") { Form_Pagar_Tarjeta fpt = new Form_Pagar_Tarjeta(bl, Cmb_Tipo_Venta.SelectedItem.ToString(), Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_SubTotal.Text), Convert.ToDecimal(Lbl_SubTotalDescuento.Text), Convert.ToDecimal(Lbl_Impuestos.Text), Convert.ToDecimal(Lbl_Total.Text), bl.ClienteExiste(Txt_Identificacion.Text).Id_cliente, 0); this.Dispose(); fpt.Show(); } else { Form_Pagar_Tarjeta fpt = new Form_Pagar_Tarjeta(bl, Cmb_Tipo_Venta.SelectedItem.ToString(), Cmb_Tipo_Pago.SelectedItem.ToString(), Convert.ToDecimal(Lbl_SubTotal.Text), Convert.ToDecimal(Lbl_SubTotalDescuento.Text), Convert.ToDecimal(Lbl_Impuestos.Text), Convert.ToDecimal(Lbl_Total.Text), bl.ClienteExiste(Txt_Identificacion.Text).Id_cliente, bl.Descuento_Aplicado(CantidadProductoTotal, DateTime.Today.DayOfWeek.ToString()).Id_DescEstandar); this.Dispose(); fpt.Show(); } } // Not relevant. for (int i = Dgv_Detalle_Factura.Rows.Count - 1; i > -1; i--) { DataGridViewRow row = Dgv_Detalle_Factura.Rows[i]; if (!row.IsNewRow && row.Cells[0].Value == null) { Dgv_Detalle_Factura.Rows.RemoveAt(i); } } for (int i = 0; i < Dgv_Detalle_Factura.RowCount; i++) { if (Dgv_Detalle_Factura.Rows[i].Cells[0].Value != null) { Descripcion_Producto = Dgv_Detalle_Factura.Rows[i].Cells[1].Value.ToString(); Codigo_Producto = Dgv_Detalle_Factura.Rows[i].Cells[2].Value.ToString(); Precio_Unitario = Dgv_Detalle_Factura.Rows[i].Cells[3].Value.ToString(); Cantidad = Dgv_Detalle_Factura.Rows[i].Cells[4].Value.ToString(); bl.AgregarProducto_DetalleFactura(Descripcion_Producto, Codigo_Producto, Convert.ToDecimal(Precio_Unitario), Convert.ToInt32(Cantidad)); } else { break; } } } }