//guardado de Datos para Pedido protected void btnAceptarDetalle_ServerClick(object sender, EventArgs e) { try { TPedido pedido = new TPedido(); pedido.Fecha = dtFechaCreacion.Date; pedido.FechaModificacion = DateTime.Today; pedido.UsuarioID = int.Parse(DataModule.Seguridad.UserID); pedido.EstacionID = 1738; pedido.ConfiguracionID = 1; pedido.Serie = System.Configuration.ConfigurationManager.AppSettings["Serie"]; pedido.Ejercisio = DateTime.Today.Year; pedido.Periodo = DateTime.Today.Month; pedido.Dia = DateTime.Today.Day; pedido.Folio = 0; if (DataModule.DataService.GuardaPedido(pedido) != -1) { Response.Write("<script>alert('Registro Insertado Exitosamente');</script>"); } else { throw new Exception("hubo un detalle, por favor contacte al administrador del sitio"); } } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
private void listPeds_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listPeds.SelectedIndex != -1) { _PedidoCollectionRegs.Clear(); TPedido p = listPedidos.ElementAt(listPeds.SelectedIndex); float importeTot = 0; int canTot = 0; foreach (TLineaPedidos l in p.TLineaPedidos) { String material; if (this.getMaterial(l.Id_material) == null) { material = "*Eliminado*"; } else { material = this.getMaterial(l.Id_material).Nombre; } float totLinea = float.Parse(Convert.ToString(l.Precio * l.Cantidad)); _PedidoCollectionRegs.Add(new PedidoData { Material = material, Cantidad = Convert.ToString(l.Cantidad), Precio = Convert.ToString(l.Precio), Total = Convert.ToString(totLinea) }); importeTot += totLinea;; canTot += l.Cantidad; } txtComs.Text = p.Observaciones; lblCant2.Content = canTot + " uds"; lblPrecio2.Content = importeTot + " €"; } }
public int GenerarFactura(TPedido Datos, TDetallePedido detallePedido) { try { int MovimientoID; int FacturaID; int DetalleFactura; int factura; if (Datos.PedidoID == 0) { IDbCommand command; using (IDataReader reader = this.ServiceSchema.GetDataReader(this.Connection, "spFolio", new string[] { "Campo", "Serie" }, new object[] { "FolioFacturacion", Datos.Serie }, out command)) { while (reader.Read()) { Datos.Folio = int.Parse(reader["Folio"].ToString()); } } } //Generar un nuevo Movimiento using (IDbCommand lcommand = this.ServiceSchema.NewCommand(this.Connection, "InsertaMovimiento", new string[] { "FechaMovimiento", "FechaVencimiento", "Referencia", "Ejercicio", "Periodo", "CargoAbono", "Cargo", "Abono", "FechaRegistro", "Origen", "AfectaSaldos", "TipoMovimientoID", "UsuarioID", "EstacionID" }, new object[] { Datos.Fecha, Datos.FechaModificacion, "Facturando", Datos.Ejercisio, Datos.Periodo, "C", "C", "", DateTime.Today, "Auto", "si", 12, Datos.UsuarioID, Datos.EstacionID })) { MovimientoID = int.Parse(lcommand.ExecuteScalar().ToString()); //return MovimientoID; FacturaID = InsertarFactura(Datos.Serie, Datos.Folio, Datos.Fecha, Datos.Ejercisio, Datos.Periodo, Datos.Dia, Datos.FechaModificacion, Datos.IVA, Datos.Observacion, 1, 1, 1, Datos.EstacionID, 1, MovimientoID); DetalleFactura = InsertarDetalleFactura(int.Parse(detallePedido.Volumen.ToString()), detallePedido.Precio, detallePedido.Subtotal, detallePedido.IVA, detallePedido.IEPS, detallePedido.Total, detallePedido.Descuento, detallePedido.NoItems, FacturaID, detallePedido.ProductoID); UpdateSaldoCargoPedido(detallePedido.Total, Datos.EstacionID); //facturacion sin pedido if (Datos.PedidoID != 0) { factura = UpdatePedidoFactura(Datos.PedidoID, FacturaID); } else { factura = Datos.PedidoID; } } return(factura); } catch (Exception ex) { throw; } }
public void registrarPedido(TPedido pedido) { IAccesoDatos dao = AccesoDatos.CreateDao(); try { dao.registrarPedido(pedido); } catch (SqlException ex) { ErrorSql e = new ErrorSql(); e.Content = "Error en la conexión con la base de datos, intentelo de nuevo, si perdura el fallo consulte con su administrador."; throw new FaultException <ErrorSql>(e); } }
public static void Invoke_GuardaPedido(RemObjects.SDK.IROService @__Instance, RemObjects.SDK.IMessage @__Message, RemObjects.SDK.Server.IServerChannelInfo @__ServerChannelInfo, out RemObjects.SDK.Server.ResponseOptions @__oResponseOptions) { RemObjects.SDK.ObjectDisposer @__ObjectDisposer = new RemObjects.SDK.ObjectDisposer(1); try { TPedido Datos = ((TPedido)(@__Message.Read("Datos", typeof(TPedido), RemObjects.SDK.StreamingFormat.Default))); @__ObjectDisposer.Add(Datos); int Result; Result = ((IRPDataService)(@__Instance)).GuardaPedido(Datos); @__Message.InitializeResponseMessage(@__ServerChannelInfo, "RPSuiteServer", "RPDataService", "GuardaPedidoResponse"); @__Message.WriteInt32("Result", Result); @__Message.FinalizeMessage(); @__oResponseOptions = RemObjects.SDK.Server.ResponseOptions.roDefault; } finally { @__ObjectDisposer.Dispose(); } }
public int GuardaPedido(TPedido pedido) { int res = -1; try { using (IDbCommand lCommand = this.ServiceSchema.NewCommand(this.Connection, "InsertPedido", new string[] { "PedidoID", "Serie", "Folio", "Fecha", "FechaModificacion", "Ejercicio", "Periodo", "Dia", "SubTotal", "IVA", "IEPS", "Total", "Descuento", "Observacion", "EstacionID", "ConfiguracionID", "UsuarioID", "StatusID", "AutoAbasto", "VehiculoID" }, new object[] { pedido.PedidoID, pedido.Serie, pedido.Folio, pedido.Fecha, pedido.FechaModificacion, pedido.Ejercisio, pedido.Periodo, pedido.Dia, pedido.Subtotal, pedido.IVA, pedido.IEPS, pedido.Total, pedido.Descuento, pedido.Observacion, pedido.EstacionID, pedido.ConfiguracionID, pedido.UsuarioID, pedido.StatusID, pedido.AutoAbasto, pedido.VehiculoID })) { res = int.Parse(lCommand.ExecuteScalar().ToString()); } return(res); } catch (Exception ex) { return(res); } }
private void Frm_DistribucionManual_Shown(object sender, EventArgs e) { txtFolioPedido.Text = Folio.ToString(); txtNombreProveedor.Text = NombreProveedor; txtTPedido.Text = TPedido.ToString(); txtCodigoArticulo.Text = CodigoArticulo; txtArticuloNombre.Text = ArticuloDescripcion; MakeTablaPedidos(); dtgValSucursales.OptionsSelection.EnableAppearanceFocusedCell = false; dtgValSucursales.OptionsSelection.EnableAppearanceHideSelection = false; dtgValSucursales.OptionsSelection.MultiSelect = true; dtgValSucursales.OptionsView.ShowGroupPanel = false; txtFolioPedido.Enabled = false; txtNombreProveedor.Enabled = false; txtTPedido.Enabled = false; txtCodigoArticulo.Enabled = false; txtArticuloNombre.Enabled = false; }
public TPedido BuscarPedido(string Datos) { TPedido res = new TPedido(); // TCliente res; // = new TCliente { ClienteID =}; try { int x = 0; IDbCommand command; using (IDataReader reader = this.ServiceSchema.GetDataReader(this.Connection, "spPedido", new string[] { "Datos" }, new object[] { Datos }, out command)) { while (reader.Read()) { // investigar si se puede pasar el Reader completo de manera directa a la variable res, res.PedidoID = (int)reader["PedidoID"]; res.Fecha = (DateTime)(reader["Fecha"] != DBNull.Value ? reader["Fecha"] : DateTime.MinValue); res.FechaModificacion = (DateTime)(reader["FechaModificacion"] != DBNull.Value ? reader["FechaModificacion"] : DateTime.MinValue); res.EstacionID = (int)(reader["EstacionID"] != DBNull.Value ? reader["EstacionID"] : -1); res.Subtotal = (double)(reader["Subtotal"] != DBNull.Value ? reader["Subtotal"] : (double)0); res.IVA = (double)(reader["IVA"] != DBNull.Value ? reader["IVA"] : (double)0); res.IEPS = (double)(reader["IEPS"] != DBNull.Value ? reader["IEPS"] : (double)0); res.Total = (double)(reader["Total"] != DBNull.Value ? reader["Total"] : (double)0); res.Descuento = (double)(reader["Descuento"] != DBNull.Value ? reader["Descuento"] : (double)0); res.UsuarioID = (int)(reader["UsuarioID"] != DBNull.Value ? reader["UsuarioID"] : -1); res.Serie = (string)(reader["Serie"] != DBNull.Value ? reader["Serie"] : ""); res.Folio = (int)(reader["Folio"] != DBNull.Value ? reader["Folio"] : 0); //res.Status = (bool)(reader["Status"] != DBNull.Value ? reader["Status"] : false); res.Observacion = (string)(reader["Observacion"] != DBNull.Value ? reader["Observacion"] : ""); res.ConfiguracionID = (int)(reader["ConfiguracionID"] != DBNull.Value ? reader["ConfiguracionID"] : -1); res.Dia = (int)(reader["Dia"] != DBNull.Value ? reader["Dia"] : -1); res.Ejercisio = (int)(reader["Ejercicio"] != DBNull.Value ? reader["Ejercicio"] : -1); } } } catch (Exception ex) { res.PedidoID = -1; } return(res); }
public void registrarPedido(TPedido pedido) { try { FisioDBDataContext dc = new FisioDBDataContext(); foreach (TLineaPedidos l in pedido.TLineaPedidos) { var materiales = from material in dc.TMaterial where material.Id_material == l.Id_material select material; l.TMaterial = materiales.First(); } dc.TPedido.InsertOnSubmit(pedido); dc.SubmitChanges(); } catch (SqlException ex) { throw ex; } }
protected void btnGuardarPedido_Click(object sender, EventArgs e) { try { List <tablapedido> lp = (List <tablapedido>)Session["LISTAPEDIDOS"]; int PedidoID = 0; foreach (tablapedido tp in lp) { TPedido pedido = new TPedido(); pedido.Fecha = dtFechaCreacion.Date; pedido.FechaModificacion = DateTime.Today; pedido.UsuarioID = int.Parse(DataModule.Seguridad.UserID); pedido.EstacionID = tp.EstacionID; pedido.ConfiguracionID = 1; pedido.Serie = System.Configuration.ConfigurationManager.AppSettings["Serie"]; pedido.Ejercisio = DateTime.Today.Year; pedido.Periodo = DateTime.Today.Month; pedido.Dia = DateTime.Today.Day; pedido.Folio = 0; pedido.StatusID = 1; pedido.AutoAbasto = tp.AutoAbasto; pedido.VehiculoID = tp.Vehiculo; PedidoID = DataModule.DataService.GuardaPedido(pedido); if (PedidoID != -1) { GuardarDetallePedido(PedidoID, tp.ProductoID, tp.Volumen, tp.Vehiculo); } else { throw new Exception("hubo un detalle, por favor contacte al administrador del sitio"); } } Response.Redirect("MenuPedido.aspx"); } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
private void btnRegistrar_Click(object sender, RoutedEventArgs e) { if (datePicker.SelectedDate == null) { lblAvisos.Content = "Selecciona una fecha."; } else if (listViewLinP.Items.Count == 0) { lblAvisos.Content = "No hay materiales en el pedido."; } else { try { pedido.Fecha = datePicker.SelectedDate.Value; pedido.Observaciones = txtComentarios.Text; ClienteWCF.getServicios().registrarPedido(pedido); this.cargarPeds(); txtPrecio.Text = ""; txtUds.Text = ""; _PedidoCollection.Clear(); lblAvisos.Content = "Pedido registrado."; txtComentarios.Text = ""; lblA3.Content = ""; pedido = new TPedido(); pedido.TLineaPedidos = new List <TLineaPedidos>(); //this.Close(); } catch (FaultException <ErrorSql> ex) { MessageBox.Show("No se ha podido registrar el pedido. " + ex.Detail.Content); } catch (EndpointNotFoundException ex) { MessageBox.Show("No es posible conectar con el servidor. Comprueba la configuración de red o contacta con tu administrador."); } } }
public VPedidos() { InitializeComponent(); pedido = new TPedido(); pedido.TLineaPedidos = new List <TLineaPedidos>(); }
private void btnGenerarRecibo_Click(object sender, EventArgs e) { try { TPedido pedido = new TPedido(); TDetallePedido detallepedido = new TDetallePedido(); pedido.PedidoID = (int)gvCatalogo.GetRowCellValue(gvCatalogo.FocusedRowHandle, "PedidoID"); //MOVIMIENTO pedido.Fecha = (DateTime)gvCatalogo.GetRowCellValue(gvCatalogo.FocusedRowHandle, "Fecha"); pedido.FechaModificacion = (DateTime)gvCatalogo.GetRowCellValue(gvCatalogo.FocusedRowHandle, "FechaModificacion"); pedido.Ejercisio = (int)gvCatalogo.GetRowCellValue(gvCatalogo.FocusedRowHandle, "Ejercicio"); pedido.Periodo = (int)gvCatalogo.GetRowCellValue(gvCatalogo.FocusedRowHandle, "Periodo"); pedido.Total = (double)gvCatalogo.GetRowCellValue(gvCatalogo.FocusedRowHandle, "Total"); pedido.UsuarioID = (int)gvCatalogo.GetRowCellValue(gvCatalogo.FocusedRowHandle, "UsuarioID"); pedido.EstacionID = (int)gvCatalogo.GetRowCellValue(gvCatalogo.FocusedRowHandle, "EstacionID"); //FACTURA pedido.Serie = txtSerie.Text; pedido.Folio = int.Parse(txtFolio.Text); pedido.Dia = (int)gvCatalogo.GetRowCellValue(gvCatalogo.FocusedRowHandle, "Dia"); pedido.IVA = (double)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "IVA"); //pedido.Status = (bool)gvCatalogo.GetRowCellValue(gvCatalogo.FocusedRowHandle, "Status"); pedido.Observacion = memObservacion.Text; //DETALLEPEDIDO detallepedido.Volumen = (int)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "Volumen"); detallepedido.Precio = (double)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "Precio"); detallepedido.Subtotal = (double)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "Subtotal"); detallepedido.IVA = (double)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "IVA"); detallepedido.IEPS = (double)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "IEPS"); detallepedido.Total = (double)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "Total"); detallepedido.Descuento = double.Parse(txtcDescuento.Text); detallepedido.NoItems = (int)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "NoItems"); detallepedido.ProductoID = (int)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "ProductoID"); //mOVIMIENTOID int MovimientoID = RedCoForm.Data.DataModule.DataService.GenerarFactura(pedido, detallepedido); if (MovimientoID <= 0) { throw new Exception("Error al generar el recibo"); } else { // int detalleFactura; // detalleFactura= RedCoForm.Data.DataModule.DataService.InsertarDetalleFactura((int)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "Volumen"), // (double)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "Precio"), // (double)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "Subtotal"), // (double)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "IVA"), // (double)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "IEPS"), // (double)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "Total"), // double.Parse(txtDescuento.Text), // (int)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "NoItems"), // MovimientoID, (int)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "ProductoID")); // //Actualiza saldo del cliente por un cargo //double saldo = RedCoForm.Data.DataModule.DataService.UpdateSaldoCargoPedido( (double)gvDetallePedido.GetRowCellValue(gvDetallePedido.FocusedRowHandle, "Total"), (int)gvCatalogo.GetRowCellValue(gvCatalogo.FocusedRowHandle, "EstacionID")); //Actualiza facturaid del pedidoid //lblFactura.Text= DataModule.DataService.UpdatePedidoFactura((int)gvCatalogo.GetRowCellValue(gvCatalogo.FocusedRowHandle, "PedidoID"), MovimientoID).ToString(); lblFactura.Text = MovimientoID.ToString(); MessageBox.Show("Recibo generado correctamente"); ButtonGenerarRecibo(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }