Beispiel #1
0
 public void IngresarDatos(string[,] m)
 {
     try
     {
         PrincipalPermission MyPermission = new PrincipalPermission(NombreUsuario, "P4");
         MyPermission.Demand();
         if (m != null)
         {
             Presupuesto_Contenido   sa = new Presupuesto_Contenido();
             Presupuesto_Contenido[] l  = sa.TableToArray(sa.SelXNumPresupuesto(idpresupuesto));
             bool esta = false;
             for (int x = 0; x < l.Length; x++)
             {
                 for (int y = 0; y < m.Length / 7; y++)
                 {
                     if (Convert.ToInt32(m[y, 0]) == l[x].Numero_Concepto && l[x].Eliminado == false)
                     {
                         esta = true;
                     }
                 }
                 if (esta == false)
                 {
                     sa.Eliminar(idpresupuesto, l[x].Numero_Concepto);
                     esta = false;
                 }
                 esta = false;
             }
             for (int x = 0; x < m.Length / 7; x++)
             {
                 Presupuesto_Contenido agregar = new Presupuesto_Contenido(idpresupuesto, Convert.ToInt32(m[x, 0]));
                 if (agregar.Numero_Concepto != 0)
                 {
                     if (agregar.Eliminado == false)
                     {
                         agregar.Actualizar(idpresupuesto, Convert.ToInt32(m[x, 0]), Convert.ToDecimal(m[x, 3]), Convert.ToInt32(m[x, 4]), Convert.ToDecimal(m[x, 5]));
                     }
                     else
                     {
                         agregar.Activar(idpresupuesto, agregar.Numero_Concepto);
                         agregar.Actualizar(idpresupuesto, Convert.ToInt32(m[x, 0]), Convert.ToDecimal(m[x, 3]), Convert.ToInt32(m[x, 4]), Convert.ToDecimal(m[x, 5]));;
                     }
                 }
                 else if (agregar.Numero_Concepto == 0)
                 {
                     agregar.Insertar(idpresupuesto, Convert.ToInt32(m[x, 0]), Convert.ToDecimal(m[x, 3]), Convert.ToInt32(m[x, 4]), Convert.ToDecimal(m[x, 5]));
                 }
             }
             Presupuesto presupuesto = new Presupuesto(idpresupuesto);
             if (presupuesto.Existe)
             {
                 presupuesto.Actualizar(idpresupuesto, presupuesto.Etiqueta, presupuesto.Nombre_Solicitante, presupuesto.Nombre_Propietario, TXT_Genero.Text, presupuesto.Mts, Convert.ToDecimal(Total.Text.Trim()), EstadoPresupuesto.SelectedIndex, IdTipodeproyecto);
             }
         }
     }
     catch (Exception ex)
     {
     }
 }