private void btnGuardar_Click(object sender, EventArgs e) { try { string rpta = ""; int cantidad = 0; float precioUnitario = 0; if (this.txtEmpleado.Text == string.Empty && this.txtCliente.Text == string.Empty) { MensajeError("Falta ingresar Algunos Datos, seran Remarcados"); errorIcono.SetError(this.txtEmpleado, "Ingrese Nombre del Empleado"); errorIcono.SetError(this.txtCliente, "Ingrese Nombre del Cliente"); } else { if (this.IsNuevo) { rpta = NOrden.Insertar(Convert.ToDateTime(txtFecha.Text), Convert.ToSingle(txtTotal.Text), Convert.ToInt32(txtEmpleado.Value), Convert.ToInt32(txtCliente.Value), Convert.ToInt32(txtTecnico.Value)); ///detalle for (int i = 0; i < detalleEquipo.RowCount; i++) { NDetalleEquipo.Insertar(Convert.ToInt32(detalleEquipo.Rows[i].Cells["id"].Value)); } ///detalle for (int i = 0; i < detalleTrabajo.RowCount; i++) { NDetalleTrabajo.Insertar(Convert.ToInt32(detalleTrabajo.Rows[i].Cells["id"].Value)); } ///detalle Repuestp for (int i = 0; i < detalleRepuesto.RowCount; i++) { cantidad = Convert.ToInt32(detalleRepuesto.Rows[i].Cells["Cantidad"].Value); precioUnitario = Convert.ToSingle(detalleRepuesto.Rows[i].Cells["Precio"].Value); NDetalleRepuesto.Insertar(cantidad, precioUnitario, Convert.ToInt32(detalleRepuesto.Rows[i].Cells["id"].Value)); } } else { rpta = NVenta.Editar(Convert.ToInt32(txtIdOrden.Text), Convert.ToDateTime(txtFecha.Text), Convert.ToSingle(txtTotal.Text), Convert.ToInt32(txtCliente.Value), Convert.ToInt32(txtEmpleado.Value)); NDetalleEquipo.Eliminar(Convert.ToInt32(this.txtIdOrden.Text)); NDetalleTrabajo.Eliminar(Convert.ToInt32(this.txtIdOrden.Text)); NDetalleRepuesto.Eliminar(Convert.ToInt32(this.txtIdOrden.Text)); ///detalle for (int i = 0; i < detalleEquipo.RowCount; i++) { NDetalleEquipo.Editar(Convert.ToInt32(detalleEquipo.Rows[i].Cells["id"].Value), Convert.ToInt32(txtIdOrden.Text)); } ///detalle for (int i = 0; i < detalleTrabajo.RowCount; i++) { NDetalleTrabajo.Editar(Convert.ToInt32(detalleTrabajo.Rows[i].Cells["id"].Value), Convert.ToInt32(txtIdOrden.Text)); } ///detalle for (int i = 0; i < detalleRepuesto.RowCount; i++) { cantidad = Convert.ToInt32(detalleRepuesto.Rows[i].Cells["Cantidad"].Value); precioUnitario = Convert.ToSingle(detalleRepuesto.Rows[i].Cells["Precio"].Value); NDetalleRepuesto.Editar(cantidad, precioUnitario, Convert.ToInt32(detalleRepuesto.Rows[i].Cells["id"].Value), Convert.ToInt32(txtIdOrden.Text)); } if (rpta.Equals("OK")) { if (this.IsNuevo) { this.MensajeOk("Se inserto Correctamente El Registro"); } else { this.MensajeOk("Se Actualizo Correctamente El Registro"); } } else { this.MensajeError(rpta); } this.IsNuevo = false; this.IsEditar = false; this.Limpiar(); this.usar = false; this.pRegistro.Visible = false; this.pListas.Visible = true; this.Mostrar(); } } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }