Esempio n. 1
0
        public formulario[] Getallform(string _action)
        {
            string sql = "";
            List<formulario> _formularios = new List<formulario>();

            using (SqlConnection _conn = Program.sqlConn())
            {
                try
                {
                    switch (_action)
                    {
                        case "0":
                            sql = string.Format("SELECT * FROM formularios");
                            break;
                        default:
                            break;
                    }
                    using (SqlCommand aCommand = new SqlCommand(sql, _conn))
                    {
                        using (SqlDataReader aReader = aCommand.ExecuteReader())
                        {
                            if (aReader.HasRows)
                            {
                                formulario _oform;
                                while (aReader.Read())
                                {
                                    _oform = new formulario();
                                    _oform.Id_formularios = int.Parse(aReader["id_formulario"].ToString());
                                    _oform.Nomb_form = aReader["nomb_form"].ToString();
                                    _oform.Desc_form = aReader["desc_form"].ToString();
                                    _oform.Id_menu = int.Parse(aReader["id_menu"].ToString());
                                    _formularios.Add(_oform);
                                }
                            }
                        }

                    }

                }
                catch
                {

                }
                return _formularios.ToArray();
            }
        }
Esempio n. 2
0
        public formulario Getformulario(string _action, string _formulario)
        {
            string sql = "";
            formulario _oformulario = new formulario();

            using (SqlConnection _conn = Program.sqlConn())
            {
                try
                {
                    switch (_action)
                    {
                        case "0":
                            sql = string.Format("SELECT * FROM formularios  where nomb_form = '{0}'", _formulario);
                            break;
                        default:
                            break;
                    }
                    using (SqlCommand aCommand = new SqlCommand(sql, _conn))
                    {
                        using (SqlDataReader aReader = aCommand.ExecuteReader())
                        {
                            if (aReader.HasRows)
                            {
                                while (aReader.Read())
                                {
                                    _oformulario.Id_formularios = int.Parse(aReader["id_formulario"].ToString());
                                    _oformulario.Nomb_form = Convert.ToString(aReader["nomb_form"]);
                                    _oformulario.Desc_form = Convert.ToString(aReader["desc_form"]);
                                    _oformulario.Id_menu = int.Parse(aReader["id_menu"].ToString());

                                }
                            }
                        }

                    }

                }
                catch
                {

                }
                return _oformulario;
            }
        }