Ejemplo n.º 1
0
        public static void Inserta()
        {
            string numero_carton_documentos;
            bool   estado_carton_documentos;
            int    id_proyectos = 5;

            DataTable dtCartonesOrigen = AccesoLogica.Select2("*", "carton_documentos", "id_carton_documentos > 0");
            int       reg = dtCartonesOrigen.Rows.Count;

            if (reg > 0)
            {
//hola
                foreach (DataRow renglon in dtCartonesOrigen.Rows)
                {
                    try
                    {
                        numero_carton_documentos = Convert.ToString(renglon["numero_carton_documentos"].ToString());
                        estado_carton_documentos = Convert.ToBoolean(renglon["estado_carton_documentos"].ToString());

                        string datos     = numero_carton_documentos + "?" + estado_carton_documentos + "?" + id_proyectos;
                        string columnas  = "_numero_carton_documentos?_estado_carton_documentos?_id_proyectos";
                        string tipodatos = "NpgsqlDbType.Varchar?NpgsqlDbType.Boolean?NpgsqlDbTypeInteger";

                        try
                        {
                            int result = AccesoLogica.Insert(datos, columnas, tipodatos, "ins_carton_documentos");
                        }
                        catch (Exception Ex)
                        {
                            MessageBox.Show(Ex.Message, "Error al Guardar", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    catch (Exception Ex)
                    {
                        MessageBox.Show(Ex.Message, "Error al Guardar", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show("No encontre Registros", "Error al Guardar", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }