Example #1
0
    /// <summary>
    /// Saves the new Route and makes the validations.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        string Name = Security.cleanSQL(TextBox1.Text);
        string Addresses = null;
        if (Page.Request["Direcciones"] != null)
        {
            Addresses = Security.cleanSQL(Page.Request["Direcciones"]);
        }

        if (Security.isEmpty(Name))
        {
            this.setNotification("warning", "¡No hay nombre de ruta!", "Ingrese un nombre de ruta por favor...");
        }
        else
        {
            Routes route = new Routes(0, Name, Addresses);

            int result = route.saveRoute();

            switch (result)
            {
                case 1:
                    Response.Redirect(webURL + "views/routes/newroute.aspx?action=notify&id=" + 1, false);
                    break;
                case -1:
                    this.setNotification("warning", "¡Campo repetido!", "Ya existe una ruta con ese nombre...");
                    break;
                default:
                    this.setNotification("error", "¡Ooooops!", "Algo salio mal...");
                    break;
            }
        }
    }
Example #2
0
    /// <summary>
    /// Edits the current Route and make the validations.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        int idRoute = Convert.ToInt16(HiddenField1.Value);
        string Name = Security.cleanSQL(TextBox1.Text);
        string Addresses = null;
        if (Page.Request["Direcciones"] != null)
        {
            Addresses = Security.cleanSQL(Page.Request["Direcciones"]);
        }

        if (Security.isEmpty(Name))
        {
            this.setNotification("warning", "¡No hay nombre de ruta!", "Ingrese un nombre de ruta por favor...");
        }
        else
        {
            Routes route = new Routes(idRoute, Name, Addresses);

            int result = route.saveRoute();

            switch (result)
            {
                case 1:
                    Response.Redirect(webURL + "views/routes/editroute.aspx?id=" + idRoute + "&action=notify&nid=" + 1, false);
                    break;
                case -1:
                    this.setNotification("warning", "¡Campo(s) repetido(s)!", "Ya existe una ruta registrado con ese nombre...");
                    break;
                case 0:
                    this.setNotification("error", "¡Ooooops!", "No existe la ruta...");
                    break;
                default:
                    this.setNotification("error", "¡Ooooops!", "Algo salio mal...");
                    break;
            }
        }
    }