private void setDataView(string id) { DataTable data = new venta().Detalle(id); if (data != null) { cargainfo = true; DataRow row = data.Rows[0]; txtCodigoVenta.Text = row["ID"].ToString(); obtenerCliente(row["ClienteID"].ToString()); tipoPago.selectedIndex = int.Parse(row["TipoPago"].ToString()); fechaVenta.Value = DateTime.Parse(row["FechaVenta"].ToString()); ventaCredito.Checked = (int.Parse(row["TipoVenta"].ToString()) == 0) ? false : true; getDetalleVenta(txtCodigoVenta.Text); cargainfo = false; } else { new popup("Error al cargar la información", popup.AlertType.error); this.DialogResult = DialogResult.Cancel; this.Close(); } }
private void guardarButton_Click(object sender, EventArgs e) { try { if (idcliente != "") { venta v = new venta(); v.Id = txtCodigoVenta.Text; v.ClientId = idcliente; v.TipoPago = tipoPago.selectedIndex; v.FechaVenta = fechaVenta.Value; v.TipoVenta = (ventaCredito.Checked) ? 1 : 0; v.SubTotal = decimal.Parse(labelSubtotal.Text); v.Tax = decimal.Parse(labelImpuesto.Text); v.MontoTotal = decimal.Parse(labelTotal.Text); if (accionformulario == "crear") { v.Insertar(); saveDetalle(1); } else { v.Editar(); saveDetalle(0); } this.DialogResult = DialogResult.OK; this.Close(); } else { new popup("No se pudo realizar la acción", popup.AlertType.error); } }catch (Exception ex) { } }