Exemplo n.º 1
0
 public void AdicionarMotivos(List <SolicitacaoComercialMotivo> motivos)
 {
     if (motivos != null)
     {
         Motivos.AddRange(motivos);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Obtener los motivos para un registro de horas extra.
        /// </summary>
        /// <param name="r">Registro para el cual se obtienen los motivos</param>
        public void obtenerMotivosRegistroHorasExtra(ref RegistroHorasExtra r)
        {
            SqlCommand    comando    = _manejador.obtenerProcedimiento("SelectRegistroHorasExtraMotivos");
            SqlDataReader datareader = null;

            _manejador.agregarParametro(comando, "@registro", r.Id, SqlDbType.Int);

            try
            {
                datareader = _manejador.ejecutarConsultaDatos(comando);

                while (datareader.Read())
                {
                    Motivos motivo = (Motivos)datareader["Motivo"];

                    r.agregarMotivo(motivo);
                }

                comando.Connection.Close();
            }
            catch (Exception)
            {
                comando.Connection.Close();
                throw new Excepcion("ErrorDatosConexion");
            }
        }
Exemplo n.º 3
0
        public ActionResult Post(bool IsNew, MotivosModel varMotivos)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _IMotivosApiConsumer.SetAuthHeader(_tokenManager.Token);



                var result      = "";
                var MotivosInfo = new Motivos
                {
                    Clave         = varMotivos.Clave
                    , Descripcion = varMotivos.Descripcion
                };

                result = !IsNew?
                         _IMotivosApiConsumer.Update(MotivosInfo, null, null).Resource.ToString() :
                             _IMotivosApiConsumer.Insert(MotivosInfo, null, null).Resource.ToString();

                Session["KeyValueInserted"] = result;
                return(Json(result, JsonRequestBehavior.AllowGet));
                //}
                //return Json(false, JsonRequestBehavior.AllowGet);
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 4
0
        public HttpResponseMessage Post(Motivos varMotivos)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varMotivos));
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsMotivos", new JavaScriptSerializer().Serialize(varMotivos), true);
                    serviceBitacora.Insert(bitacora);
                }
                catch (ServiceException ex)
                {
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsMotivos", new JavaScriptSerializer().Serialize(varMotivos), true);
                    serviceBitacora.Insert(bitacora);
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
            }
            else
            {
                var errors   = ModelState.SelectMany(m => m.Value.Errors.Select(err => err.ErrorMessage != string.Empty ? err.ErrorMessage : err.Exception.Message).ToList()).ToList();
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsMotivos", new JavaScriptSerializer().Serialize(varMotivos), false, errors.ToString());
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }
Exemplo n.º 5
0
        public HttpResponseMessage Delete(int id)
        {
            Motivos varMotivos = this.service.GetByKey(id, false);
            bool    result     = false;

            if (varMotivos == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            try
            {
                result = this.service.Delete(id);//, globalData, dataReference);
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelMotivos", new JavaScriptSerializer().Serialize(varMotivos), result);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelMotivos", new JavaScriptSerializer().Serialize(varMotivos), result, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Exemplo n.º 6
0
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            Motivos entity = this.service.ListaSelAll(1, 1, "Motivos.Clave='" + id.ToString() + "'", "").Motivoss.First();
            Motivos result = new Motivos();

            result.Clave       = entity.Clave;
            result.Descripcion = entity.Descripcion;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
 private void AgregarMotivo(Motivo _motivo)
 {
     if (_motivo != null)
     {
         Motivos.Add(_motivo);
         gAna.gv4.LogEvent(new EventHitBuilder()
                           .SetEventCategory("Motivo")
                           .SetEventAction(SceneManager.GetActiveScene().name)
                           .SetEventLabel(dialogoActual.NombrePersonaje));
         gAna.gv4.DispatchHits();
     }
 }
Exemplo n.º 8
0
        public HttpResponseMessage PutTunnel(Motivos emp, string user, string password)
        {
            var client = new System.Net.WebClient();

            client.Headers = TokenManager.GetAuthenticationHeader(user, password);
            client.Headers["Content-Type"] = "application/json";
            var dataString = new JavaScriptSerializer().Serialize(emp);

            var result = client.UploadString(new Uri(baseApi + ApiControllerUrl + "/Put?Id=" + emp.Clave), "PUT"
                                             , dataString);

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Desligar un motivo de un registro de horas extra.
        /// </summary>
        /// <param name="r">Objeto RegistroHorasExtra con los datos del registro</param>
        /// <param name="m">Motivo a desligar del registro</param>
        public void eliminarMotivoRegistroHorasExtra(RegistroHorasExtra r, Motivos m)
        {
            SqlCommand comando = _manejador.obtenerProcedimiento("DeleteRegistroHorasExtraMotivo");

            _manejador.agregarParametro(comando, "@motivo", m, SqlDbType.TinyInt);
            _manejador.agregarParametro(comando, "@registro", r.Id, SqlDbType.Int);

            try
            {
                _manejador.ejecutarConsultaActualizacion(comando);
                comando.Connection.Close();
            }
            catch (Exception)
            {
                comando.Connection.Close();
                throw new Excepcion("ErrorRegistroHorasExtraActualizacion");
            }
        }
Exemplo n.º 10
0
        public HttpResponseMessage Put_Datos_Generales(Motivos varMotivos_Datos_Generales)
        {
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Update_Datos_Generales(varMotivos_Datos_Generales));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varMotivos_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdMotivos", new JavaScriptSerializer().Serialize(varMotivos_Datos_Generales), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varMotivos_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdMotivos", new JavaScriptSerializer().Serialize(varMotivos_Datos_Generales), false, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
Exemplo n.º 11
0
        public HttpResponseMessage MotivosGenerateID()
        {
            Motivos varMotivos = new Motivos();
            var     data       = "-1";

            try
            {
                data = Convert.ToString(this.service.Insert(varMotivos));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_MotivosGenerateID", new JavaScriptSerializer().Serialize(varMotivos), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_MotivosGenerateID", new JavaScriptSerializer().Serialize(varMotivos), true);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
Exemplo n.º 12
0
        public ActionResult Delete(int id)
        {
            try
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _IMotivosApiConsumer.SetAuthHeader(_tokenManager.Token);

                Motivos varMotivos = null;
                if (id.ToString() != "0")
                {
                    string where = "";
                }
                var result = _IMotivosApiConsumer.Delete(id, null, null).Resource;
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 13
0
        public string AnalisaRetornoEnvio(string sRet)
        {
            try
            {
                string         sCabec         = "";
                string         sDetalhes      = "";
                XElement       xDoc           = XElement.Parse(sRet, LoadOptions.None);
                List <Motivos> objListMotivos = new List <Motivos>();

                foreach (XElement item in xDoc.Descendants())
                {
                    switch (item.Name.LocalName.ToString())
                    {
                    case "xMotivo":
                    {
                        if (sCabec == "")
                        {
                            sCabec = string.Format("{0} {1}{1}", item.Value.ToString(), Environment.NewLine);
                        }
                    }
                    break;
                    }
                    if (item.Name.LocalName.ToString().Equals("retEvento"))
                    {
                        Motivos objMotivo = new Motivos();
                        foreach (XElement st in item.Descendants())
                        {
                            switch (st.Name.LocalName.ToString())
                            {
                            case "xMotivo": { objMotivo.xMotivo = st.Value.ToString(); }
                            break;

                            case "chNFe": { objMotivo.chave = st.Value.ToString(); }
                            break;

                            case "cStat": { objMotivo.Status = st.Value.ToString(); }
                            break;
                            }
                        }
                        objListMotivos.Add(objMotivo);
                    }
                }

                foreach (Motivos mot in objListMotivos)
                {
                    string sNota     = objlItensPesquisa.FirstOrDefault(c => c.CHNFE == mot.chave).CD_NOTAFIS;
                    int    iQT_ENVIO = objlItensPesquisa.FirstOrDefault(c => c.CHNFE == mot.chave).QT_ENVIO;
                    string sNR_LANC  = objlItensPesquisa.FirstOrDefault(c => c.CHNFE == mot.chave).CD_NRLANC;
                    if (mot.Status == "135")
                    {
                        AtualizaContadorCCe(sNR_LANC, iQT_ENVIO);
                        // SaveXmlPastaCCe(mot.chave);
                        SalvaRetornoCCe(mot.chave, sRet);
                    }
                    sDetalhes += string.Format("CCe da NFe: {0} - '{1}'{2}", sNota, mot.xMotivo, Environment.NewLine);
                }

                return(sCabec + sDetalhes);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 14
0
        public string AnalisaRetornoEnvio(string sRet)
        {
            try
            {
                string sCabec = "";
                string sDetalhes = "";
                XElement xDoc = XElement.Parse(sRet, LoadOptions.None);
                List<Motivos> objListMotivos = new List<Motivos>();

                foreach (XElement item in xDoc.Descendants())
                {
                    switch (item.Name.LocalName.ToString())
                    {
                        case "xMotivo":
                            {
                                if (sCabec == "")
                                {
                                    sCabec = string.Format("{0} {1}{1}", item.Value.ToString(), Environment.NewLine);
                                }
                            }
                            break;
                    }
                    if (item.Name.LocalName.ToString().Equals("retEvento"))
                    {
                        Motivos objMotivo = new Motivos();
                        foreach (XElement st in item.Descendants())
                        {
                            switch (st.Name.LocalName.ToString())
                            {
                                case "xMotivo": { objMotivo.xMotivo = st.Value.ToString(); }
                                    break;
                                case "chNFe": { objMotivo.chave = st.Value.ToString(); }
                                    break;
                                case "cStat": { objMotivo.Status = st.Value.ToString(); }
                                    break;
                            }
                        }
                        objListMotivos.Add(objMotivo);

                    }
                }

                foreach (Motivos mot in objListMotivos)
                {
                    string sNota = objlItensPesquisa.FirstOrDefault(c => c.CHNFE == mot.chave).CD_NOTAFIS;
                    int iQT_ENVIO = objlItensPesquisa.FirstOrDefault(c => c.CHNFE == mot.chave).QT_ENVIO;
                    string sNR_LANC = objlItensPesquisa.FirstOrDefault(c => c.CHNFE == mot.chave).CD_NRLANC;
                    if (mot.Status == "135")
                    {
                        AtualizaContadorCCe(sNR_LANC, iQT_ENVIO);
                        // SaveXmlPastaCCe(mot.chave);
                        SalvaRetornoCCe(mot.chave, sRet);

                    }
                    sDetalhes += string.Format("CCe da NFe: {0} - '{1}'{2}", sNota, mot.xMotivo, Environment.NewLine);
                }

                return sCabec + sDetalhes;

            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// Quitar un motivo del registro.
 /// </summary>
 /// <param name="motivo">Motivo a quitar</param>
 public void quitarMotivo(Motivos motivo)
 {
     _motivos.Remove(motivo);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Agregar un motivo para el registro.
 /// </summary>
 /// <param name="motivo">Motivo a agregar</param>
 public void agregarMotivo(Motivos motivo)
 {
     _motivos.Add(motivo);
 }