예제 #1
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            XmlDocument xd = new XmlDocument();

            xd.Load(Server.MapPath("../App_Data/" + DropDownList2.SelectedValue.ToString() + ".xml"));
            XmlNodeList tareas    = xd.GetElementsByTagName("tarea");
            int         n         = tareas.Count;
            string      tareasrep = "";

            for (int i = 0; i < n; i++)
            {
                if (!dBManager.tareaRepetida(tareas[i].Attributes["codigo"].Value.ToString()))
                {
                    DataRow dr = dt.NewRow();
                    dr["Codigo"]      = tareas[i].Attributes["codigo"].Value.ToString();
                    dr["Descripcion"] = tareas[i].ChildNodes[0].InnerText.ToString();
                    dr["CodAsig"]     = DropDownList2.SelectedValue.ToString();
                    dr["HEstimadas"]  = int.Parse(tareas[i].ChildNodes[1].InnerText);
                    dr["Explotacion"] = bool.Parse(tareas[i].ChildNodes[2].InnerText);
                    dr["TipoTarea"]   = tareas[i].ChildNodes[3].InnerText.ToString();
                    dt.Rows.Add(dr);
                }
                else
                {
                    if (i < n - 2)
                    {
                        tareasrep = tareasrep + tareas[i].Attributes["codigo"].Value.ToString() + ", ";
                    }
                    else if (i == n - 2)
                    {
                        tareasrep = tareasrep + tareas[i].Attributes["codigo"].Value.ToString() + " y ";
                    }
                    else if (i == n - 1)
                    {
                        tareasrep = tareasrep + tareas[i].Attributes["codigo"].Value.ToString() + ".";
                    }
                }
            }

            da.UpdateCommand = cb.GetUpdateCommand();
            da.Update(ds, "TareasGenericas");
            da.Update(dt);


            if (tareasrep != "")
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('¡Tareas insertadas! Advertencia - Las siguientes tareas no se han insertado al tener código repetido: " + tareasrep + "');", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('¡Las tareas se han añadido exitosamente!');", true);
            }
        }
예제 #2
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (!dBManager.tareaRepetida(TextBox1.Text.ToString()))
     {
         DataRow dr = dt.NewRow();
         dr["Codigo"]      = TextBox1.Text.ToString();
         dr["Descripcion"] = TextBox3.Text.ToString();
         dr["CodAsig"]     = DropDownList1.Text.ToString();
         dr["HEstimadas"]  = TextBox2.Text.ToString();
         dr["Explotacion"] = false;
         dr["TipoTarea"]   = DropDownList2.Text.ToString();
         dt.Rows.Add(dr);
         da.UpdateCommand = cb.GetUpdateCommand();
         da.Update(ds, "TareasGenericas");
         da.Update(dt);
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('¡Tarea añadida con éxito!')", true);
     }
     else
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('La tarea que intenta añadir tiene un código ya utilizado.')", true);
     }
 }