Ejemplo n.º 1
0
        public static int Prox_Codigo(string tabla)
        {
            string sql = "";

            Clases.ETipo ii_Tipo = new Clases.ETipo();
            DataSet      DS      = new DataSet();
            string       Error   = "";
            string       campo   = "";
            string       tipo    = "";

            sql = "select COLUMN_NAME,DATA_TYPE from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = '" + tabla + "' and ORDINAL_POSITION = 1";
            DS  = funciones.EjecutaSQL(sql, ref Error);
            if (DS.Tables[0].Rows.Count > 0)
            {
                campo = DS.Tables[0].Rows[0]["COLUMN_NAME"].ToString();
            }

            sql = "  SELECT isnull(MAX(" + campo + "),0) from  " + tabla;
            DS  = funciones.EjecutaSQL(sql, ref Error);
            if (DS.Tables[0].Rows.Count > 0)
            {
                return(int.Parse(DS.Tables[0].Rows[0][0].ToString()) + 1);
            }
            return(0);
        }
Ejemplo n.º 2
0
        public static string Lee_Descr_Gen(string id, string tabla)
        {
            string sql = "";

            Clases.ETipo ii_Tipo = new Clases.ETipo();
            DataSet      DS      = new DataSet();
            string       Error   = "";
            string       campo   = "";
            string       tipo    = "";

            sql = "select COLUMN_NAME,DATA_TYPE from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = '" + tabla + "' and ORDINAL_POSITION = 1";
            DS  = funciones.EjecutaSQL(sql, ref Error);
            if (DS.Tables[0].Rows.Count > 0)
            {
                campo = DS.Tables[0].Rows[0]["COLUMN_NAME"].ToString();
                tipo  = DS.Tables[0].Rows[0]["DATA_TYPE"].ToString();
            }

            sql = "  SELECT * from  " + tabla + " WHERE  " + campo + " = '" + id + "'";
            DS  = funciones.EjecutaSQL(sql, ref Error);
            if (DS.Tables[0].Rows.Count > 0)
            {
                return(DS.Tables[0].Rows[0][1].ToString());
            }
            return("");
        }
Ejemplo n.º 3
0
 private void tid_Leave(object sender, EventArgs e)
 {
     if (tid.Text.ToString().Trim() != "")
     {
         if (tid.Text.ToString().Trim() == "*")
         {
             tid.Text = funciones.Prox_Codigo(aa_tabla).ToString("######");
         }
         else
         {
             aa_ETipo = funciones.Lee_Tipo(tid.Text.ToString().Trim(), aa_tabla);
             if (aa_ETipo != null)
             {
                 aa_modo     = "m";
                 tDESCR.Text = aa_ETipo.descripcion;
                 if (aa_ETipo.estado.ToUpper() == "A")
                 {
                     CB_ESTADO.SelectedIndex = 0;
                 }
                 else
                 {
                     CB_ESTADO.SelectedIndex = 1;
                 }
             }
             else
             {
                 Valida_codigo();
             }
         }
     }
 }
Ejemplo n.º 4
0
 public Pant_Gen(string ii_modo, string ii_tabla, string ii_titulo, Clases.ETipo ii_Etipo)
 {
     InitializeComponent();
     aa_modo      = ii_modo;
     aa_tabla     = ii_tabla;
     aa_titulo    = ii_titulo;
     LTitulo.Text = aa_titulo.ToUpper();
     aa_ETipo     = ii_Etipo;
 }
Ejemplo n.º 5
0
        public static Clases.ETipo Lee_Tipo(string id, string tabla, string campo)
        {
            Clases.ETipo ii_Tipo = new Clases.ETipo();
            DataSet      DS      = new DataSet();
            string       Error   = "";
            string       sql     = "  SELECT * from  " + tabla + " WHERE  " + campo + " = '" + id + "'";

            DS = funciones.EjecutaSQL(sql, ref Error);
            if (DS.Tables[0].Rows.Count > 0)
            {
                ii_Tipo.id          = id;
                ii_Tipo.descripcion = DS.Tables[0].Rows[0][1].ToString();
                ii_Tipo.estado      = DS.Tables[0].Rows[0][2].ToString();
                return(ii_Tipo);
            }
            return(null);
        }
Ejemplo n.º 6
0
        void Modificar()
        {
            int i = Fila_Actual();

            Id = DG_DATOS.Rows[i].Cells[0].Value.ToString().Trim();
            //if (aa_tabla.ToString().Trim().ToUpper() == "GRUPO_ARTICULO")
            //{
            //    Grupo_art form = new Grupo_art("m", Id);
            //    if (form.ShowDialog() == DialogResult.OK)
            //        Lee_Datos();
            //}
            //else
            //{
            Clases.ETipo ii_Tipo = funciones.Lee_Tipo(Id, aa_tabla);
            Pant_Gen     form    = new Pant_Gen("m", aa_tabla, "MODIFICA " + aa_titulo, ii_Tipo);

            if (form.ShowDialog() == DialogResult.OK)
            {
                Lee_Datos();
            }
            //  }
        }
Ejemplo n.º 7
0
        public static Clases.ETipo Lee_Tipo(string id, string tabla)
        {
            string sql = "";

            Clases.ETipo ii_Tipo = new Clases.ETipo();
            DataSet      DS      = new DataSet();
            string       Error   = "";
            string       campo   = "";
            string       tipo    = "";

            sql = "select COLUMN_NAME,DATA_TYPE from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = '" + tabla + "' and ORDINAL_POSITION = 1";
            DS  = funciones.EjecutaSQL(sql, ref Error);
            if (DS.Tables[0].Rows.Count > 0)
            {
                campo = DS.Tables[0].Rows[0]["COLUMN_NAME"].ToString();
                tipo  = DS.Tables[0].Rows[0]["DATA_TYPE"].ToString();
            }

            sql = "  SELECT * from  " + tabla + " WHERE  " + campo + " = '" + id + "'";
            DS  = funciones.EjecutaSQL(sql, ref Error);
            if (DS.Tables[0].Rows.Count > 0)
            {
                ii_Tipo.id          = id;
                ii_Tipo.descripcion = DS.Tables[0].Rows[0][1].ToString();
                ii_Tipo.estado      = DS.Tables[0].Rows[0][2].ToString();
                if (tipo.ToString().Trim().ToLower() == "int")
                {
                    ii_Tipo.Tipo_PK_int = true;
                }
                else
                {
                    ii_Tipo.Tipo_PK_int = false;
                }
                return(ii_Tipo);
            }
            return(null);
        }