Exemplo n.º 1
0
        public DataTable ShowName(DPresentation presentation)
        {
            DataTable     DtResult = new DataTable("presentation");
            SqlConnection SqlCon   = new SqlConnection();

            try{
                SqlCon.ConnectionString = Conection.cn;
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "spsearch_presentation_name";
                SqlCmd.CommandType = CommandType.StoredProcedure;


                SqlParameter ParSearch = new SqlParameter();
                ParSearch.ParameterName = "@textsearch";
                ParSearch.SqlDbType     = SqlDbType.VarChar;
                ParSearch.Size          = 50;
                ParSearch.Value         = presentation.Textsearch;
                SqlCmd.Parameters.Add(ParSearch);


                SqlDataAdapter SqlData = new SqlDataAdapter(SqlCmd);
                SqlData.Fill(DtResult);
            }catch (Exception ex)
            {
                DtResult = null;
            }
            return(DtResult);
        }
Exemplo n.º 2
0
        public string Insert(DPresentation presentation)
        {
            string        resp   = "";
            SqlConnection SqlCon = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = Conection.cn;
                SqlCon.Open();

                SqlCommand SqlCmd = new SqlCommand();

                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "spinsert_presentation";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                //Initialize variables
                SqlParameter ParIdPresentation = new SqlParameter();
                ParIdPresentation.ParameterName = "@idpresentation";
                ParIdPresentation.SqlDbType     = SqlDbType.Int;
                ParIdPresentation.Direction     = ParameterDirection.Output;

                SqlCmd.Parameters.Add(ParIdPresentation);

                SqlParameter ParName = new SqlParameter();
                ParName.ParameterName = "@name";
                ParName.SqlDbType     = SqlDbType.VarChar;
                ParName.Size          = 50;
                ParName.Value         = presentation.Name;

                SqlCmd.Parameters.Add(ParName);

                SqlParameter ParDesc = new SqlParameter();
                ParDesc.ParameterName = "@description";
                ParDesc.SqlDbType     = SqlDbType.VarChar;
                ParDesc.Size          = 256;
                ParDesc.Value         = presentation.Description;

                SqlCmd.Parameters.Add(ParDesc);

                //Execute the command
                resp = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "Not Inserted";
            }
            catch (Exception ex)
            {
                resp = "Something went wrong: " + ex.Message;
            }
            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }
            return(resp);
        }
Exemplo n.º 3
0
        public string Delete(DPresentation category)
        {
            string        resp   = "";
            SqlConnection SqlCon = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = Conection.cn;
                SqlCon.Open();

                SqlCommand SqlCmd = new SqlCommand();

                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "spdelete_presentation";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                //Initialize variables
                SqlParameter ParIdPresentation = new SqlParameter();
                ParIdPresentation.ParameterName = "@idpresentation";
                ParIdPresentation.SqlDbType     = SqlDbType.Int;
                ParIdPresentation.Value         = category.Idpresentation;

                SqlCmd.Parameters.Add(ParIdPresentation);



                //Execute the command
                resp = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "Not deleted";
            }
            catch (Exception ex)
            {
                resp = "Something went wrong: " + ex.Message;
            }
            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }

            return(resp);
        }