Esempio n. 1
0
        public int registrarPostVentaCliente(PostVenta pv)
        {
            int afectadas = 0;

            SqlConnection  cnn = new SqlConnection();
            SqlCommand     cmd = new SqlCommand();
            SqlTransaction t   = null;

            try
            {
                cnn.ConnectionString = string_conexion;
                cnn.Open();

                t = cnn.BeginTransaction();

                cmd.Connection  = cnn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "registrarServiceCliente";
                cmd.Parameters.AddWithValue("@unidad", pv.unidad.CodUnidad);
                cmd.Parameters.AddWithValue("@km", pv.Kmlimite);
                cmd.Transaction = t;
                afectadas       = cmd.ExecuteNonQuery();
                //foreach (DetallePostVenta dpv in pv.Detalles)
                //{
                // ARROJA SQL EXCEPTION → EL PROCEDIMIENTO TIENE DEMASIADOS ARGUMENTOS
                //    cmd.CommandText = "registrarDetalleServiceCliente";
                //    cmd.Parameters.AddWithValue("@unidad", pv.unidad.CodUnidad);
                //    cmd.Parameters.AddWithValue("@trabajo", dpv.Job.IdTrabajo);
                //    cmd.Parameters.AddWithValue("@precio", dpv.Precio);
                //    cmd.Parameters.AddWithValue("@descripcion", dpv.Descripcion);
                //    afectadas += cmd.ExecuteNonQuery();
                //}
                cmd.CommandType = CommandType.Text;
                foreach (DetallePostVenta dpv in pv.Detalles)
                {
                    cmd.CommandText = "registrarDetalleServiceCliente " + pv.unidad.CodUnidad + ", " + dpv.Job.IdTrabajo + ", " + dpv.Precio + ", '" + dpv.Descripcion + "'";
                    cmd.Transaction = t;
                    afectadas      += cmd.ExecuteNonQuery();
                }

                t.Commit();
            }
            catch (Exception ex)
            {
                if (t != null)
                {
                    t.Rollback();
                    afectadas = 0;
                }
                MessageBox.Show("EXPLOTO EL HELPER", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw ex;
            }
            finally
            {
                this.CloseConnection(cnn);
            }

            return(afectadas);
        }
Esempio n. 2
0
 public frm_detalle_pv(int seleccionada, int unidadSeleccionada)
 {
     InitializeComponent();
     uService            = new UnidadService();
     pvService           = new PostVentaService();
     this.pvSeleccionado = pvService.getPostVentaMasDetalle(seleccionada, unidadSeleccionada);
     this.uSeleccionada  = uService.getUnidadPorId(unidadSeleccionada);
 }
Esempio n. 3
0
 public frm_new_service(int unidad, int opcion)
 {
     uService           = new UnidadService();
     pvService          = new PostVentaService();
     newPostventa       = new PostVenta();
     job                = new Trabajo();
     unidadSeleccionada = uService.getUnidadParaService(unidad);
     this.opcion        = opcion;
     InitializeComponent();
 }
Esempio n. 4
0
 public bool registrarServiceCliente(PostVenta service)
 {
     return(dao.registrarNuevoServiceCliente(service));
 }
Esempio n. 5
0
 public bool registrarServiceInterno(PostVenta service)
 {
     return(dao.registrarNuevoServiceInterno(service));
 }