Example #1
0
    protected void btn_grabar_Click(object sender, EventArgs e)
    {
        SiteBC    s   = new SiteBC();
        DataTable dt  = s.ObtenerTodos();
        DataTable dt2 = new DataTable();

        dt2.Columns.Add("SITE_ID");
        dt2.Columns.Add("COLOR");
        bool exito = true;

        foreach (DataRow dr in dt.Rows)
        {
            TextBox txtsite = (TextBox)pnl_Sites.FindControl("txt_colorSite_" + dr["ID"].ToString());
            if (string.IsNullOrEmpty(txtsite.Text))
            {
                //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "error", "alert('Debe completar todos los datos');", true);
                exito = false;
                break;
            }
            else
            {
                dt2.Rows.Add(dr["ID"].ToString(), txtsite.Text);
            }
        }
        if (exito)
        {
            SolicitudBC sol = new SolicitudBC();
            if (sol.EditarColorEstadoSite(dt2, int.Parse(hf_id.Value)))
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ok", "alert('Todo OK');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "error", "alert('Error');", true);
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "error", "alert('Debe completar todos los datos');", true);
        }
        //DropDownList ddlzona = (DropDownList)panel_temp.FindControl(dr["SITE_ID"].ToString() + "ZONA__DDL");    // new DropDownList();
    }