Exemplo n.º 1
0
        public ActionResult vpFiltroServicio(string pagina, string idnegocio)
        {
            try
            {
                string sError = "";

                if (pagina == null)
                {
                    pagina = "1";
                }

                DetalleServicio ctrlDetalleServicio = new DetalleServicio();

                ctrlDetalleServicio.CargaServicioNegocios(pagina, idnegocio, out sError);

                ViewBag.Idnegocio    = idnegocio;
                ViewBag.PaginaActual = pagina;

                return(PartialView(ctrlDetalleServicio));
            }
            catch (Exception e)
            {
                ViewBag.Error = e.Message;
                return(PartialView());
            }
        }
        public Boolean Guardar(int idVehiculo, int idServicio)
        {
            DetalleServicio d   = new DetalleServicio();
            SqlConnection   con = Conexion.Instancia().conectar();

            //SqlConnection con = new SqlConnection(Properties.Settings.Default.con);
            SqlCommand cmd = new SqlCommand("Cliente_Insertar_PA", con);

            string sql = @" SELECT Lavado, Encerado, Motor, idDetalleServicio
                            FROM DetalleServicio
                            INNER JOIN Vehiculo
                             ON Vehiculo.Vehiculo=DetalleServicio.idVehiculo
                            WHERE Placa = @placa AND FechaServicio = @fecha";

            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter paramId = new SqlParameter("idDetalleServicio", SqlDbType.Int);

            paramId.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(paramId);

            cmd.Parameters.AddWithValue("idVehiculo", d.idVehiculo);
            cmd.Parameters.AddWithValue("idServicio", d.idServicio);
            cmd.Parameters.AddWithValue("Lavado", d.Lavado);
            cmd.Parameters.AddWithValue("Encerado", d.Encerado);
            cmd.Parameters.AddWithValue("Motor", d.Motor);
            cmd.Parameters.AddWithValue("FechaServicio", d.FechaServicio);


            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            d.idDetalleServicio = (Int32)paramId.Value;
            return(true);
        }
Exemplo n.º 3
0
        protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            try
            {
                using (var conexion = new DataModelFE())
                {
                    DetalleServicio detalleServicio = (DetalleServicio)Session["detalleServicio"];
                    var             id   = e.Values["codigo.codigo"].ToString();
                    LineaDetalle    dato = detalleServicio.lineaDetalle.Where(x => x.codigo.codigo == id).FirstOrDefault();
                    detalleServicio.lineaDetalle.Remove(dato);

                    //esto es para el manero del devexpress
                    e.Cancel = true;
                    this.ASPxGridView1.CancelEdit();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(Utilidades.validarExepcionSQL(ex), ex.InnerException);
            }
            finally
            {
                //refescar los datos
                this.refreshData();
            }
        }
Exemplo n.º 4
0
        public HttpResponseMessage Put(FormDataCollection form)
        {
            OtrosCargos otroscargos = new OtrosCargos();

            otroscargos.TipoDocumento1          = form.Get("TipoDoc");
            otroscargos.NumeroIdentidadTercero1 = form.Get("NumIdTercero");
            otroscargos.NombreTercero1          = form.Get("NombreTercero");
            otroscargos.Detalle1    = form.Get("Detalle");
            otroscargos.Porcentaje1 = Convert.ToDecimal(form.Get("Porcentaje"));
            otroscargos.MontoCargo1 = Convert.ToDecimal(form.Get("MontoCargo"));

            Factura clavefactura = new Factura();

            clavefactura.Clave1 = form.Get("Clave");
            DetalleServicio clave = new DetalleServicio();

            clave.Clave1       = clavefactura;
            otroscargos.Clave1 = clave;

            string[] respuesta = new string[2];
            respuesta[0] = otroscargos.Insert_OtrosCargos();
            respuesta[1] = form.Get("Clave");

            HttpResponseMessage response = Request.CreateResponse <string[]>(HttpStatusCode.Created, respuesta);

            return(response);
        }
Exemplo n.º 5
0
        public HttpResponseMessage Put(FormDataCollection form)
        {
            Models.Factura         factura         = new Factura();
            Models.DetalleServicio detalleservicio = new DetalleServicio();


            factura.CodigoActividad1   = form.Get("CodActividad");
            factura.Clave1             = form.Get("Clave");
            factura.NumeroConsecutivo1 = form.Get("NumConsecutivo");
            factura.FechaEmision1      = Convert.ToDateTime(form.Get("FechaEmision"));

            Identificacion idemisor = new Identificacion();

            idemisor.Numero1 = form.Get("Emisor");
            Persona emisor = new Persona();

            emisor.IdentificacionNumero1 = idemisor;
            factura.EmisorPersona1       = emisor;

            Identificacion idreceptor = new Identificacion();

            idreceptor.Numero1 = form.Get("Receptor");
            Persona receptor = new Persona();

            receptor.IdentificacionNumero1 = idreceptor;
            factura.ReceptorPersona1       = receptor;

            factura.CondicionVenta1 = form.Get("CondVenta");
            factura.PlazoCredito1   = form.Get("PlazoCredito");
            factura.MedioPago1      = form.Get("MedioPago");

            var msgadevolver = factura.Insert_Factura();

            DetalleServicio detalleservicio1 = new DetalleServicio();

            detalleservicio1.Clave1 = factura;

            JArray jObject = JArray.Parse(form.Get("LineaDetalleFactura"));
            JToken jUser3  = jObject;
            var    lista   = jUser3.ToObject <List <lineadetalle_local> >();
            List <LineaDetalle> listalineadetalleobj = new List <LineaDetalle>();

            foreach (lineadetalle_local item in lista)
            {
                LineaDetalle lineadetalle = new LineaDetalle();
                lineadetalle.Consecutivo1 = Convert.ToInt32(item.Consecutivo1);
                listalineadetalleobj.Add(lineadetalle);
            }
            detalleservicio1.LineaDetalleFactura1 = listalineadetalleobj;

            detalleservicio1.Insert_DetalleServicio();

            string[] respuesta = new string[2];
            respuesta[0] = msgadevolver;
            respuesta[1] = form.Get("Clave");

            HttpResponseMessage response = Request.CreateResponse <string[]>(HttpStatusCode.Created, respuesta);

            return(response);
        }
Exemplo n.º 6
0
        public ActionResult FiltroServicio(string id)
        {
            try
            {
                string sError    = "";
                string idnegocio = "";

                DetalleServicio ctrlDetalleServicio = new DetalleServicio();

                if (idnegocio != null)
                {
                    idnegocio = ctrlDetalleServicio.CargaNegocio(id, out sError);
                }

                ctrlDetalleServicio.CargaNegocios(out sError);

                ViewBag.Error     = sError;
                ViewBag.Idnegocio = idnegocio;

                return(View(ctrlDetalleServicio));
            }
            catch (Exception e)
            {
                ViewBag.Error = e;
                return(View(ViewBag.Error));
            }
        }
Exemplo n.º 7
0
        private void btnIngresoGuardarDatos_Click(object sender, EventArgs e)
        {
            string vacuna = "";

            if (rdbSI.Checked)
            {
                vacuna = rdbSI.Text;
            }

            if (rdbNO.Checked)
            {
                vacuna = rdbNO.Text;
            }

            double total = double.Parse(txtTotal.Text);

            DetalleServicio detalle = new DetalleServicio(txtDetalleRevision.Text, cmbServicio.SelectedItem.ToString(), vacuna, dtpFecha.Text, total);

            control.ListaDeDetalles.Add(detalle);

            foreach (var detail in control.ListaDeDetalles)
            {
                MessageBox.Show("servicio hecho is :" + detail.DetalleRevision + "vacuna :" + detail.ProgramaVacuna);
            }
        }
Exemplo n.º 8
0
        public HttpResponseMessage Get()
        {
            DetalleServicio detalleservicio = new DetalleServicio();

            HttpResponseMessage response = Request.CreateResponse <List <Models.DetalleServicio> >(HttpStatusCode.Created, detalleservicio.Select_Todo_DetalleServicio());

            return(response);
        }
Exemplo n.º 9
0
        public ActionResult DeleteConfirmed(int id)
        {
            DetalleServicio detalleServicio = db.DetalleServicios.Find(id);

            db.DetalleServicios.Remove(detalleServicio);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 10
0
 /// <summary>
 /// carga inicial de todos los registros
 /// </summary>
 private void refreshData()
 {
     if (Session["detalleServicio"] != null)
     {
         DetalleServicio detalleServicio = (DetalleServicio)Session["detalleServicio"];
         this.ASPxGridView1.DataSource = detalleServicio.lineaDetalle;
         this.ASPxGridView1.DataBind();
     }
 }
Exemplo n.º 11
0
        public String DetalleCabecera(string idcomponente)
        {
            string sError = "";
            JavaScriptSerializer varjon       = new JavaScriptSerializer();
            DetalleServicio      ctrlElemento = new DetalleServicio();

            ctrlElemento.CargaCabeceraReporteComponente(idcomponente, out sError);

            ViewBag.Error = sError;

            return(varjon.Serialize(ctrlElemento.CabeceraReporteJson));
        }
Exemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "Costo,Tiempo,detalleServicioID,tipoServiciosID,ordenServicioID")] DetalleServicio detalleServicio)
 {
     if (ModelState.IsValid)
     {
         db.Entry(detalleServicio).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ordenServicioID = new SelectList(db.OrdenServicios, "ordenServicioID", "Estado", detalleServicio.ordenServicioID);
     ViewBag.tipoServiciosID = new SelectList(db.TipoServicios, "tipoServiciosID", "Servicio", detalleServicio.tipoServiciosID);
     return(View(detalleServicio));
 }
Exemplo n.º 13
0
        public String DetalleInfraestructura(string idservicionegocio)
        {
            string sError = "";

            JavaScriptSerializer varjon = new JavaScriptSerializer();
            DetalleServicio      ctrlDetalleServicio = new DetalleServicio();

            ctrlDetalleServicio.CargaInfraestructura(idservicionegocio, out sError);

            ViewBag.Error = sError;

            return(varjon.Serialize(ctrlDetalleServicio.infraestructuraJson));
        }
Exemplo n.º 14
0
        // GET: DetalleServicios/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DetalleServicio detalleServicio = db.DetalleServicios.Find(id);

            if (detalleServicio == null)
            {
                return(HttpNotFound());
            }
            return(View(detalleServicio));
        }
Exemplo n.º 15
0
        public void SetDetalle(DetalleServicio detalle)
        {
            Detalle = detalle;
            chkObligatorio.Checked = detalle.Obligatorio;

            switch (detalle.Tipo)
            {
            case DetalleCiclo.TipoTiempo:
                txtMinutos.Text = detalle.Minutos.ToString();
                break;

            case DetalleCiclo.TipoEvento:
                if (detalle.Mensaje != null)
                {
                    var tipoEvento = detalle.Mensaje.TipoMensaje.Id.ToString();
                    var evento     = detalle.Mensaje.Codigo;
                    if (cbTipoEvento.SelectedValue != tipoEvento)
                    {
                        cbTipoEventoWrapper.BindingManager.BindTipoMensaje(cbTipoEventoWrapper);
                    }
                    cbTipoEvento.SelectedValue = tipoEvento;
                    if (cbEventos.SelectedValue != evento)
                    {
                        cbEventosWrapper.BindingManager.BindMensajes(cbEventosWrapper);
                    }
                    cbEventos.SelectedValue = evento;
                }
                break;

            case DetalleCiclo.TipoEntradaPoi:
            case DetalleCiclo.TipoSalidaPoi:
                if (detalle.ReferenciaGeografica != null)
                {
                    var tipoGeoRef = detalle.ReferenciaGeografica.TipoReferenciaGeografica.Id.ToString();
                    var geoRef     = detalle.ReferenciaGeografica.Id.ToString();
                    if (cbTipoReferenciaGeografica.SelectedValue != tipoGeoRef)
                    {
                        cbTipoReferenciaGeograficaWrapper.BindingManager.BindTipoReferenciaGeografica(cbTipoReferenciaGeograficaWrapper);
                    }
                    cbTipoReferenciaGeografica.SelectedValue = tipoGeoRef;
                    cbReferenciaGeograficaWrapper.BindingManager.BindReferenciaGeografica(cbReferenciaGeograficaWrapper);
                    cbReferenciaGeografica.SelectedValue = geoRef;
                }

                break;
            }

            dtProgramada.SelectedDate = detalle.Programada.ToDisplayDateTime();
        }
Exemplo n.º 16
0
        public HttpResponseMessage Get([FromUri] String id)
        {
            OtrosCargos otroscargos = new OtrosCargos();

            Factura clavefactura = new Factura();

            clavefactura.Clave1 = id;
            DetalleServicio clave = new DetalleServicio();

            clave.Clave1       = clavefactura;
            otroscargos.Clave1 = clave;

            HttpResponseMessage response = Request.CreateResponse <Models.OtrosCargos>(HttpStatusCode.Created, otroscargos.Select_OtrosCargos());

            return(response);
        }
Exemplo n.º 17
0
        // GET: DetalleServicios/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DetalleServicio detalleServicio = db.DetalleServicios.Find(id);

            if (detalleServicio == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ordenServicioID = new SelectList(db.OrdenServicios, "ordenServicioID", "Estado", detalleServicio.ordenServicioID);
            ViewBag.tipoServiciosID = new SelectList(db.TipoServicios, "tipoServiciosID", "Servicio", detalleServicio.tipoServiciosID);
            return(View(detalleServicio));
        }
Exemplo n.º 18
0
    public string GuardarOrdenCIEX(object Objeto)
    {
        JavaScriptSerializer obj      = new JavaScriptSerializer();
        Servicio             Servicio = obj.ConvertToType <Servicio>(Objeto);

        List <DetalleServicio> Detalle = Servicio.Detalle;

        foreach (DetalleServicio Det in Detalle)
        {
            DetalleServicio DS = Det;
            Console.WriteLine(Det.Destino);
        }

        InsertarDb(Servicio);

        return(Servicio.Enca.Puesto);
    }
Exemplo n.º 19
0
        public HttpResponseMessage Delete(FormDataCollection form)
        {
            DetalleServicio detalleservicio = new DetalleServicio();

            Factura clave = new Factura();

            clave.Clave1           = form.Get("Clave");
            detalleservicio.Clave1 = clave;

            string[] respuesta = new string[2];
            respuesta[0] = detalleservicio.Delete_DetalleServicio();
            respuesta[1] = form.Get("Clave");

            HttpResponseMessage response = Request.CreateResponse <string[]>(HttpStatusCode.Created, respuesta);

            return(response);
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            using (var db = new modelContextLp())
            {
                var detalle = new DetalleServicio
                {
                    _descripcion = "son los detalles",
                    _horaInicio  = DateTime.Parse("2017-04-20"),
                    _horaTermino = DateTime.Parse("2017-04-29"),
                    _mensaje     = "HOLA",
                    _precio      = 39494,
                    _fechaInicio = DateTime.Parse("2017-04-20"),
                    _promocion   = 23
                };
                db.Detalles.Add(detalle);
                db.SaveChanges();
                // Create and save a new Blog
                Console.Write("Enter a name for a new Blog: ");
                var name = Console.ReadLine();
                var tot  = Console.ReadLine();

                var servicio = new Servicio {
                    _nombre = name, _total = Decimal.Parse(tot)
                };
                db.Servicios.Add(servicio);

                db.SaveChanges();

                // Display all Blogs from the database
                var query = from b in db.Servicios
                            orderby b._nombre, b._total
                select b;

                Console.WriteLine("All blogs in the database:");
                foreach (var item in query)
                {
                    Console.WriteLine(item._nombre);
                    Console.WriteLine(item._total);
                    Console.WriteLine(item._detalles.ToList());
                }

                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
        }
Exemplo n.º 21
0
        public static void ActualizarDetalleHojaServicio(DetalleServicio detalle, SqlTransaction objTx)
        {
            SqlCommand cmd = new SqlCommand();

            try
            {
                cmd.CommandText = "usp_DetalleServicio_u";

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = objTx.Connection;
                cmd.Transaction = objTx;

                cmd.Parameters.Add(new SqlParameter("@iddetalleHojaServicio", SqlDbType.Int)).Value = detalle.iddetalleHojaServicio;

                if (detalle.HoraInicio != string.Empty)
                {
                    cmd.Parameters.Add(new SqlParameter("@HoraInicio", SqlDbType.VarChar, 10)).Value = detalle.HoraInicio;
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("@HoraInicio", SqlDbType.VarChar, 10)).Value = DBNull.Value;
                }

                if (detalle.HoraFin != string.Empty)
                {
                    cmd.Parameters.Add(new SqlParameter("@HoraFin", SqlDbType.VarChar, 10)).Value = detalle.HoraFin;
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("@HoraFin", SqlDbType.VarChar, 10)).Value = DBNull.Value;
                }

                cmd.Parameters.Add(new SqlParameter("@Estado", SqlDbType.Char, 3)).Value = detalle.Estado;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                cmd = null;
            }
        }
Exemplo n.º 22
0
        public HttpResponseMessage Delete(FormDataCollection form)
        {
            OtrosCargos otroscargos = new OtrosCargos();

            Factura clavefactura = new Factura();

            clavefactura.Clave1 = form.Get("Clave");
            DetalleServicio clave = new DetalleServicio();

            clave.Clave1       = clavefactura;
            otroscargos.Clave1 = clave;

            string[] respuesta = new string[2];
            respuesta[0] = otroscargos.Delete_OtrosCargos();
            respuesta[1] = form.Get("Clave");

            HttpResponseMessage response = Request.CreateResponse <string[]>(HttpStatusCode.Created, respuesta);

            return(response);
        }
        public async Task <IActionResult> InsertDetalleServicio([FromBody] DetalleServicioViewModel detalleServicio)
        {
            try
            {
                Guid          guidOrden = new Guid(detalleServicio.OrdenId);
                OrdenServicio orden     = await _ordenServicioRepository.GetOrdenServicioBiId(guidOrden);

                DetalleServicio obj = new DetalleServicio(detalleServicio.Detalle, orden);

                await _ordenServicioRepository.InsertDetalleServicio(obj);

                await _unitOfWork.Commit();

                return(Ok());
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool eliminarServicioDetalles(string id)
        {
            try
            {
                ModelosContext mc  = new ModelosContext();
                int            sId = Convert.ToInt32(id);

                Servicio        datos  = mc.Servicios.Include(d => d.DetalleServicio).Where(sd => sd.Id == sId).FirstOrDefault();
                DetalleServicio datos2 = mc.Detalles.Where(d => d.Id == datos.idDetalle).FirstOrDefault();
                mc.Servicios.Remove(datos);
                mc.Detalles.Remove(datos2);
                mc.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 25
0
        public DetalleServicio Guardar(String placa, DateTime fecha)
        {
            /*string sql = @"SELECT *
             *        FROM DetalleServicio
             *        WHERE idVehiculo = @vehiculo AND FechaServicio = @fecha";*/

            string sql = @" SELECT Lavado, Encerado, Motor, idDetalleServicio
                            FROM DetalleServicio
                            INNER JOIN Vehiculo
                             ON Vehiculo.Vehiculo=DetalleServicio.idVehiculo
                            WHERE Placa = @placa AND FechaServicio = @fecha";


            SqlConnection con = Conexion.Instancia().conectar();
            //SqlConnection con = new SqlConnection(Properties.Settings.Default.con);
            SqlCommand command = new SqlCommand(sql, con);

            command.Parameters.AddWithValue("@placa", placa);

            //string hash = Helper.EncodePassword(string.Concat(usuario, password));
            //command.Parameters.AddWithValue("@password", hash);
            command.Parameters.AddWithValue("@fecha", fecha);
            con.Open();


            DetalleServicio obj = new DetalleServicio();

            SqlDataReader dr = command.ExecuteReader();

            while (dr.Read())
            {
                obj.idDetalleServicio = (Int32)dr["idDetalleServicio"];
                obj.idVehiculo        = (Int32)dr["idVehiculo"];
                obj.Lavado            = (Boolean)dr["Lavado"];
                obj.Encerado          = (Boolean)dr["Encerado"];
                obj.Motor             = (Boolean)dr["Motor"];
            }

            con.Close();
            return(obj);
        }
Exemplo n.º 26
0
        public ActionResult Ver(string id)
        {
            try
            {
                string sError = "";

                JavaScriptSerializer varjon = new JavaScriptSerializer();
                DetalleServicio      ctrlDetalleServicio = new DetalleServicio();

                ctrlDetalleServicio.CargaInfraestructura(id, out sError);

                ViewBag.Error             = sError;
                ViewBag.IdServicioNegocio = id;
                ViewBag.ServicioNegocio   = ctrlDetalleServicio.CargaNombreServicioNegocio(id, out sError);

                return(View(ctrlDetalleServicio));
            }
            catch (Exception e)
            {
                ViewBag.Error = e;
                return(View(ViewBag.Error));
            }
        }
Exemplo n.º 27
0
        public ActionResult DetalleServicio(string id, string idservicionegocio, string ambiente)
        {
            try
            {
                string sError = "";

                DetalleServicio ctrlDetalleServicio = new DetalleServicio();

                ctrlDetalleServicio.CargaDetalleInfraestructura(id, idservicionegocio, ambiente, out sError);

                ViewBag.PaginaActual      = id;
                ViewBag.ambiente          = ambiente;
                ViewBag.Error             = sError;
                ViewBag.IdServicioNegocio = idservicionegocio;
                ViewBag.ServicioNegocio   = ctrlDetalleServicio.CargaNombreServicioNegocio(idservicionegocio, out sError);

                return(View(ctrlDetalleServicio));
            }
            catch (Exception e)
            {
                ViewBag.Error = e;
                return(View(ViewBag.Error));
            }
        }
Exemplo n.º 28
0
        protected void btngrabarejecutar_Click(object sender, EventArgs e)
        {
            try
            {
                //Validando campos obligatorios
                if (txtfechaemisionalt.Text == string.Empty)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Ingrese la fecha de emisión.'});", true);
                    return;
                }
                //Guardando cabecera
                HojaServicio hoja = new HojaServicio();
                hoja.idHojaServicio = Utilidades.ToInt(hfidHojaServicio.Value);
                hoja.FechaEmision   = txtfechaemisionalt.Text;
                hoja.Observaciones  = txtobservacionesejecutar.Text;

                //Guardando detalles
                List <DetalleServicio> lista    = new List <DetalleServicio>();
                DropDownList           ddestado = default(DropDownList);
                DropDownList           empleado = default(DropDownList);
                TextBox txthorainicio           = default(TextBox);
                TextBox txthorafin = default(TextBox);

                DetalleServicio item = null;
                for (Int32 i = 0; i <= grvResultadoPopup.Rows.Count - 1; i++)
                {
                    item = new DetalleServicio();

                    item.iddetalleHojaServicio = Utilidades.ToInt(this.grvResultadoPopup.DataKeys[i].Values[0].ToString());
                    ddestado      = (DropDownList)grvResultadoPopup.Rows[i].FindControl("cboEstadoser");
                    empleado      = (DropDownList)grvResultadoPopup.Rows[i].FindControl("cboEmpleadoServ");
                    txthorainicio = (TextBox)grvResultadoPopup.Rows[i].FindControl("txtHorainicio");
                    txthorafin    = (TextBox)grvResultadoPopup.Rows[i].FindControl("txtHoraFin");

                    if (ddestado.SelectedValue == "002")
                    {
                        if (txthorainicio.Text == string.Empty)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Ingrese la hora de inicio.'});", true);
                            return;
                        }

                        if (txthorafin.Text == string.Empty)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Ingrese la hora de Fin.'});", true);
                            return;
                        }

                        if (empleado.SelectedValue == "0")
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Seleccione el empleado que ejecuto el servicio.'});", true);
                            return;
                        }
                    }

                    item.Estado     = ddestado.SelectedValue;
                    item.HoraInicio = txthorainicio.Text;
                    item.HoraFin    = txthorafin.Text;
                    lista.Add(item);
                }


                AtencionPeluqueriaBuss.GrabarHojaServicio(hoja, lista, 2);
                ListarHojas();
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal('hide');", true);
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal2", "callbusqueda();", true);
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Error interno del sistema.'});", true);
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal('hide');", true);
                //this.lblmsg.Text = ex.Message;
            }
        }
Exemplo n.º 29
0
        protected async void btnCrearNota_Click(object sender, EventArgs e)
        {
            try
            {
                Thread.CurrentThread.CurrentCulture = Utilidades.getCulture();


                List <string> cc        = new List <string>();
                Regex         validator = new Regex(@"\s*\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\s*");

                foreach (var correo in this.txtCorreoReceptor.Tokens)
                {
                    if (validator.IsMatch(correo))
                    {
                        cc.Add(correo);
                    }
                    else
                    {
                        this.alertMessages.Attributes["class"] = "alert alert-danger";
                        this.alertMessages.InnerText           = String.Format("Favor verifique el formato de la dirección {0}", correo);
                        return;
                    }
                }
                cc.RemoveAt(0);


                DetalleServicio detalle = (DetalleServicio)Session["detalleServicio"];
                if (detalle.lineaDetalle.Count == 0)
                {
                    this.alertMessages.Attributes["class"] = "alert alert-danger";
                    this.alertMessages.InnerText           = "Debe agregar almenos una linea de detalle a la factura";
                    return;
                }

                // datos de la factura original
                FacturaElectronica factura = new FacturaElectronica();
                string             clave   = Session["clave"].ToString();
                using (var conexion = new DataModelFE())
                {
                    WSRecepcionPOST datoPost   = conexion.WSRecepcionPOST.Find(clave);
                    string          xmlFactura = datoPost.comprobanteXml;
                    factura = (FacturaElectronica)EncodeXML.XMLUtils.getObjetcFromXML(xmlFactura, typeof(FacturaElectronica));

                    DocumentoElectronico dato = null;
                    if (TipoDocumento.NOTA_CREDITO.Equals(Session["tipoNota"].ToString()))
                    {
                        dato = new NotaCreditoElectronica();
                    }
                    else
                    {
                        dato = new NotaDebitoElectronica();
                    }


                    /* ENCABEZADO */
                    dato.medioPago      = factura.medioPago;
                    dato.plazoCredito   = factura.plazoCredito;
                    dato.condicionVenta = factura.condicionVenta;
                    dato.fechaEmision   = Date.DateTimeNow().ToString("yyyy-MM-ddTHH:mm:ss") + "-06:00";
                    /* DETALLE */
                    dato.detalleServicio = detalle;

                    /* EMISOR */
                    dato.emisor = factura.emisor;


                    /* RECEPTOR */
                    dato.receptor = factura.receptor;


                    /* INFORMACION DE REFERENCIA */
                    InformacionReferencia informacionReferencia = new InformacionReferencia();
                    informacionReferencia.numero        = factura.clave;
                    informacionReferencia.fechaEmision  = factura.fechaEmision;
                    informacionReferencia.codigo        = this.cmbCodigoReferencia.Value.ToString();
                    informacionReferencia.razon         = this.txtRazón.Text;
                    informacionReferencia.tipoDocumento = TipoDocumento.FACTURA_ELECTRONICA;
                    dato.informacionReferencia.Add(informacionReferencia);

                    /* RESUMEN */
                    dato.resumenFactura.tipoCambio   = factura.resumenFactura.tipoCambio;
                    dato.resumenFactura.codigoMoneda = factura.resumenFactura.codigoMoneda;
                    foreach (var item in dato.detalleServicio.lineaDetalle)
                    {
                        if (item.tipoServMerc == null)
                        {
                            Producto producto = conexion.Producto.Where(x => x.codigo == item.codigo.codigo && x.emisor == dato.emisor.identificacion.numero).FirstOrDefault();
                            item.tipoServMerc = producto.tipoServMerc;
                            item.producto     = producto.codigo;
                        }
                    }
                    dato.resumenFactura.calcularResumenFactura(dato.detalleServicio.lineaDetalle);

                    /* VERIFICA VACIOS PARA XML */
                    dato.verificaDatosParaXML();

                    //genera el consecutivo del documento
                    string   sucursal = this.cmbSucursalCaja.Value.ToString().Substring(0, 3);
                    string   caja     = this.cmbSucursalCaja.Value.ToString().Substring(3, 5);
                    object[] key      = new object[] { dato.emisor.identificacion.numero, sucursal, caja, this.cmbTipoDocumento.Value.ToString() };
                    ConsecutivoDocElectronico consecutivo = conexion.ConsecutivoDocElectronico.Find(key);
                    if (consecutivo != null)
                    {
                        dato.clave             = consecutivo.getClave(Date.DateTimeNow().ToString("yyyyMMdd"));
                        dato.numeroConsecutivo = consecutivo.getConsecutivo();

                        consecutivo.consecutivo          += 1;
                        conexion.Entry(consecutivo).State = EntityState.Modified;
                    }
                    else
                    {
                        consecutivo                   = new ConsecutivoDocElectronico();
                        consecutivo.sucursal          = ConsecutivoDocElectronico.DEFAULT_SUCURSAL;
                        consecutivo.caja              = ConsecutivoDocElectronico.DEFAULT_CAJA;
                        consecutivo.digitoVerificador = ConsecutivoDocElectronico.DEFAULT_DIGITO_VERIFICADOR;
                        consecutivo.emisor            = dato.emisor.identificacion.numero;
                        consecutivo.tipoDocumento     = this.cmbTipoDocumento.Value.ToString();
                        consecutivo.consecutivo       = 1;
                        consecutivo.estado            = Estado.ACTIVO.ToString();
                        consecutivo.fechaCreacion     = Date.DateTimeNow();

                        dato.clave             = consecutivo.getClave(Date.DateTimeNow().ToString("yyyyMMdd"));
                        dato.numeroConsecutivo = consecutivo.getConsecutivo();

                        consecutivo.consecutivo += 1;
                        conexion.ConsecutivoDocElectronico.Add(consecutivo);
                    }

                    EmisorReceptorIMEC elEmisor     = (EmisorReceptorIMEC)Session["elEmisor"];
                    string             responsePost = await Services.enviarDocumentoElectronico(false, dato, elEmisor, this.cmbTipoDocumento.Value.ToString(), Session["usuario"].ToString());

                    if (responsePost.Equals("Success"))
                    {
                        this.alertMessages.Attributes["class"] = "alert alert-info";
                        this.alertMessages.InnerText           = String.Format("Documento #{0} enviada.", dato.numeroConsecutivo);

                        if (!string.IsNullOrWhiteSpace(dato.receptor.correoElectronico) || this.txtCorreoReceptor.Tokens.Count > 0)
                        {
                            string xml = EncodeXML.XMLUtils.getXMLFromObject(dato);

                            Utilidades.sendMail(Session["emisor"].ToString(), dato.receptor.correoElectronico,
                                                string.Format("{0} - {1}", dato.numeroConsecutivo, elEmisor.nombre),
                                                Utilidades.mensageGenerico(), "Documento Electrónico", xml, dato.numeroConsecutivo, dato.clave, cc);
                        }
                    }
                    else if (responsePost.Equals("Error"))
                    {
                        this.alertMessages.Attributes["class"] = "alert alert-danger";
                        this.alertMessages.InnerText           = String.Format("Documento #{0} con errores.", dato.numeroConsecutivo);
                        return;
                    }
                    else
                    {
                        this.alertMessages.Attributes["class"] = "alert alert-warning";
                        this.alertMessages.InnerText           = String.Format("Documento #{0} pendiente de envío", dato.numeroConsecutivo);
                    }

                    conexion.SaveChanges();


                    Response.Redirect("~/Pages/Consulta/" + dato.clave);
                }
            }
            catch (Exception ex)
            {
                this.alertMessages.Attributes["class"] = "alert alert-danger";
                this.alertMessages.InnerText           = Utilidades.validarExepcionSQL(ex);
            }
            finally
            {
                //refescar los datos
                this.refreshData();
            }
        }
Exemplo n.º 30
0
        protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            try
            {
                using (var conexion = new DataModelFE())
                {
                    DetalleServicio detalleServicio = (DetalleServicio)Session["detalleServicio"];

                    string       codProducto = e.NewValues["codigo.codigo"] != null ? e.NewValues["codigo.codigo"].ToString().ToUpper() : null;
                    LineaDetalle dato        = detalleServicio.lineaDetalle.Where(x => x.codigo.codigo == codProducto).FirstOrDefault();
                    //llena el objeto con los valores de la pantalla

                    Producto producto        = conexion.Producto.Where(x => x.codigo == codProducto).FirstOrDefault();
                    decimal  tontoTotalLinea = dato.montoTotalLinea;

                    //dato.numeroLinea = detalleServicio.lineaDetalle.Count;
                    dato.cantidad = e.NewValues["cantidad"] != null?decimal.Parse(e.NewValues["cantidad"].ToString()) : 0;

                    //dato.codigo.tipo = producto.tipo;
                    //dato.codigo.codigo = producto.codigo;
                    //dato.detalle = producto.descripcion;
                    //dato.unidadMedida = producto.unidadMedida;
                    dato.unidadMedidaComercial = "";

                    decimal precio = "0".Equals(e.NewValues["precioUnitario"].ToString()) ? producto.precioVenta1 : decimal.Parse(e.NewValues["precioUnitario"].ToString());

                    dato.producto       = producto.codigo;/*solo para uso del grid*/
                    dato.precioUnitario = precio;
                    dato.montoDescuento = e.NewValues["montoDescuento"] != null?decimal.Parse(e.NewValues["montoDescuento"].ToString()) : 0;

                    dato.montoTotal = dato.subTotal - dato.montoDescuento;
                    dato.calcularMontos();

                    dato.naturalezaDescuento = e.NewValues["naturalezaDescuento"] != null ? e.NewValues["naturalezaDescuento"].ToString().ToUpper() : null;
                    dato.naturalezaDescuento = dato.naturalezaDescuento;

                    if (TipoDocumento.NOTA_CREDITO.Equals(Session["tipoNota"].ToString()))
                    {
                        if (tontoTotalLinea < dato.montoTotalLinea)
                        {
                            throw new Exception(string.Format("El monto de la línea de la nota de crédito no puede ser mayor al original {0}", tontoTotalLinea));
                        }
                    }

                    //agrega el objeto
                    Session["detalleServicio"] = detalleServicio;
                }

                //esto es para el manero del devexpress
                e.Cancel = true;
                this.ASPxGridView1.CancelEdit();
            }
            catch (Exception ex)
            {
                throw new Exception(Utilidades.validarExepcionSQL(ex), ex.InnerException);
            }
            finally
            {
                //refescar los datos
                this.refreshData();
            }
        }