예제 #1
0
    public static string WGrabarOt(string sId, string sNumero, string sFecha, string sIdClienteMunicipio, string sIdRuta, string sIdCamion,
                                   string sNombreChoferes, string sCorreos, string sHora)
    {
        JavaScriptSerializer scriptSerializer = new JavaScriptSerializer();
        List <string>        Lista            = new List <string>();
        Usuario usr = new Usuario();

        if (!UtilWeb.CheckSession(Lista, ref usr, HttpContext.Current))
        {
            return(scriptSerializer.Serialize(Lista.ToArray()));
        }

        try
        {
            if (sCorreos.Trim().Length == 0)
            {
                Lista.Add("error");
                Lista.Add("Ingrese el dato: Correos");
                return(scriptSerializer.Serialize(Lista.ToArray()));
            }

            if (!UtilWeb.IsValidMail(sCorreos.Trim()))
            {
                Lista.Add("error");
                Lista.Add("El dato Correos está incorrecto");
                return(scriptSerializer.Serialize(Lista.ToArray()));
            }

            double IdNew = 0;
            Ot     ot    = new Ot(usr);
            usr.ReadMunic();
            sIdClienteMunicipio = UtilWeb.GetDatoSingular("Id", usr.oClienteMunicipio.Datos);

            if (sId.Trim().Length == 0)
            {
                IdNew = ot.Create(sNumero, sFecha, sIdClienteMunicipio, sIdRuta, sIdCamion, sNombreChoferes, sCorreos, sHora, "0", "0");
            }
            else
            {
                ot.Update(sId, sNumero, sFecha, sIdClienteMunicipio, sIdRuta, sIdCamion, sNombreChoferes, sCorreos, sHora, "0", "0");
            }

            //WLeerUsuarioConectadoAndMunicipios_Internal(usr, ref html);

            Lista.Add("Exito");
            Lista.Add(string.Format("OT: {0}", IdNew.ToString()));
        }
        catch (Exception ex)
        {
            Lista.Add("Exception");
            Lista.Add(ex.Message);
            Lista.Add("Hubo un error no controlado en la aplicación, por favor inténtelo nuevamente, si el problema persiste contactarse con el administrador sistemas para revisar el log de eventos del servidor.");
        }
        return(scriptSerializer.Serialize(Lista.ToArray()));
    }
예제 #2
0
    public static string WGrabarMunicipio(string sId, string sNombreMunic, string sRutMunic, string sNombreUserMunic, string sRutUserMunic, string sCorreoUserMunic,
                                          string sClave, string sClave2, string sTelefono, string sLogo)
    {
        JavaScriptSerializer scriptSerializer = new JavaScriptSerializer();
        List <string>        Lista            = new List <string>();
        Usuario usr = new Usuario();

        if (!UtilWeb.CheckSession(Lista, ref usr, HttpContext.Current))
        {
            return(scriptSerializer.Serialize(Lista.ToArray()));
        }

        try
        {
            if (sId.Trim().Length != 0)
            {
                if (sClave != sClave2)
                {
                    Lista.Add("CSD");
                    return(scriptSerializer.Serialize(Lista.ToArray()));
                }

                if (sCorreoUserMunic == "")
                {
                    Lista.Add("CORREO_NO");
                    return(scriptSerializer.Serialize(Lista.ToArray()));
                }
                bool res = UtilWeb.IsValidMail(sCorreoUserMunic);
                if (!res)
                {
                    Lista.Add("CORREO_NO");
                    return(scriptSerializer.Serialize(Lista.ToArray()));
                }


                if (sRutMunic == "")
                {
                    Lista.Add("RUT_NO");
                    return(scriptSerializer.Serialize(Lista.ToArray()));
                }
                if (!UtilWeb.IsValidRut(sRutMunic))
                {
                    Lista.Add("RUT_NO");
                    return(scriptSerializer.Serialize(Lista.ToArray()));
                }

                if (sRutUserMunic == "")
                {
                    Lista.Add("RUT_USER_NO");
                    return(scriptSerializer.Serialize(Lista.ToArray()));
                }
                if (!UtilWeb.IsValidRut(sRutUserMunic))
                {
                    Lista.Add("RUT_USER_NO");
                    return(scriptSerializer.Serialize(Lista.ToArray()));
                }
            }

            ClienteMunicipio cliente = new ClienteMunicipio(usr);
            if (sId.Trim().Length == 0)
            {
                //cliente.Create(sNombreMunic, sRutMunic, sNombreUserMunic, sRutUserMunic, sCorreoUserMunic, sClave, sTelefono);
                sId = cliente.Create(sNombreMunic, sRutMunic, sNombreUserMunic, sRutUserMunic, sCorreoUserMunic, sClave, sTelefono).ToString();
            }
            else
            {
                cliente.Update(sId, sNombreMunic, sRutMunic, sNombreUserMunic, sRutUserMunic, sCorreoUserMunic, sClave, sTelefono);
            }


            if (sLogo.Trim().Length != 0 && !sLogo.Contains("image-placeholder.png"))
            {
                //data:image/png;base64,djsjsadkjadjkhadfkadkfakhdfkjhadkjh
                sLogo = sLogo.Substring(sLogo.IndexOf("base64,") + "base64,".Length);
                byte[] bytes = Convert.FromBase64String(sLogo);
                File.WriteAllBytes(string.Format(HttpContext.Current.Server.MapPath("~/images") + "\\MunLog_{0}.jpg", sId), bytes);
            }


            string html = "";
            WLeerUsuarioConectadoAndMunicipios_Internal(usr, ref html);

            Lista.Add("Exito");
            Lista.Add(html);
        }
        catch (Exception ex)
        {
            Lista.Add("Exception");
            Lista.Add(ex.Message);
            Lista.Add("Hubo un error no controlado en la aplicación, por favor inténtelo nuevamente, si el problema persiste contactarse con el administrador sistemas para revisar el log de eventos del servidor.");
        }
        return(scriptSerializer.Serialize(Lista.ToArray()));
    }