Exemplo n.º 1
0
        public static List <myshares> myshares(String email)
        {
            List <myshares> mm          = new List <myshares>();
            SqlDataReader   reader      = null;
            String          queryString = "SELECT psxrecord.noofstocks, psxrecord.compname, psxrecord.priceofshare FROM (person inner join psxperson on person.cnic= psxperson.cnic) inner join psxrecord on psxrecord.psxaccno=psxperson.psxaccno WHERE '" + email + "'=person.email";
            SqlConnection   con         = new SqlConnection(connectionString);
            SqlCommand      cmd         = new SqlCommand(queryString, con);

            try
            {
                con.Open();
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    int      noofstocks   = (int)reader["noofstocks"];
                    string   compname     = (string)reader["compname"];
                    double   priceofshare = Convert.ToDouble(reader["priceofshare"]);
                    myshares k            = new myshares();
                    k.noofstocks  = noofstocks;
                    k.compname    = compname;
                    k.priceoshare = priceofshare;
                    mm.Add(k);
                }
            }
            catch (SqlException ex)
            {
                Console.WriteLine("SQL Error" + ex.Message.ToString());
                return(null);
            }
            finally
            {
                con.Close();
            }
            return(mm);
        }
Exemplo n.º 2
0
        // -------------------------------------------------person --------------------------------------------
        public static List <myshares> matchthedeal(double r1, double r2, int n1, int n2, int shv1, int shv2)
        {
            List <myshares> mm          = new List <myshares>();
            SqlDataReader   reader      = null;
            String          queryString = "SELECT stocksellercomp.nipostosell,stocksellercomp.compname,stocksellercomp.facevalue FROM stocksellercomp WHERE(((stocksellercomp.facevalue >= " + shv1 + ") and(stocksellercomp.facevalue <= " + shv2 + ")) and((stocksellercomp.nipostosell >= " + n1 + ") and(" + n2 + " >= stocksellercomp.nipostosell)) and((stocksellercomp.dividend >=" + r1 + ") and(stocksellercomp.dividend >= " + r2 + ")))";

            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand    cmd = new SqlCommand(queryString, con);

            try
            {
                con.Open();
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    int      noofstocks   = (int)reader["nipostosell"];
                    string   compname     = (string)reader["compname"];
                    double   priceofshare = Convert.ToDouble(reader["facevalue"]);
                    myshares k            = new myshares();
                    k.noofstocks  = noofstocks;
                    k.compname    = compname;
                    k.priceoshare = priceofshare;
                    mm.Add(k);
                }
            }
            catch (SqlException ex)
            {
                Console.WriteLine("SQL Error" + ex.Message.ToString());
                return(null);
            }


            queryString = "SELECT buybrokercomp.nipostosell,buybrokercomp.compname,psxcompany.faceval FROM buybrokercomp inner join psxcompany on buybrokercomp.compregno = psxcompany.regno  WHERE((psxcompany.faceval >=" + shv1 + ") and (psxcompany.faceval <=" + shv2 + ") and(buybrokercomp.nipostosell >=" + n1 + ") and (buybrokercomp.nipostosell >=" + n2 + ") and(psxcompany.dividend >= " + r1 + ") and (psxcompany.dividend >= " + r2 + ") ) ";
            con         = new SqlConnection(connectionString);
            cmd         = new SqlCommand(queryString, con);
            try
            {
                con.Open();
                while (reader.Read())
                {
                    int      noofstocks   = (int)reader["nipostosell"];
                    string   compname     = (string)reader["compname"];
                    double   priceofshare = Convert.ToDouble(reader["faceval"]);
                    myshares k            = new myshares();
                    k.noofstocks  = noofstocks;
                    k.compname    = compname;
                    k.priceoshare = priceofshare;
                    mm.Add(k);
                }
            }
            catch (SqlException ex)
            {
                Console.WriteLine("SQL Error" + ex.Message.ToString());
                return(null);
            }


            queryString = "SELECT stockseller.sharevoffr,stockseller.nstockstosell,psxcompany.compname FROM stockseller inner join psxcompany on stockseller.compname = psxcompany.compname WHERE((stockseller.sharevoffr >= " + shv1 + ") and (stockseller.sharevoffr <= " + shv2 + ") and(stockseller.nstockstosell >= " + n1 + ") and (stockseller.nstockstosell >=" + n2 + ") and(psxcompany.dividend >=" + r1 + ") and (psxcompany.dividend >= " + r2 + ") )";
            con         = new SqlConnection(connectionString);
            cmd         = new SqlCommand(queryString, con);
            try
            {
                con.Open();
                while (reader.Read())
                {
                    int      noofstocks   = (int)reader["nstockstosell"];
                    string   compname     = (string)reader["compname"];
                    double   priceofshare = Convert.ToDouble(reader["sharevoffr"]);
                    myshares k            = new myshares();
                    k.noofstocks  = noofstocks;
                    k.compname    = compname;
                    k.priceoshare = priceofshare;
                    mm.Add(k);
                }
            }
            catch (SqlException ex)
            {
                Console.WriteLine("SQL Error" + ex.Message.ToString());
                return(null);
            }
            queryString = "SELECT buybrokerperson.compname,buybrokerperson.sharevalue,buybrokerperson.noofshares  FROM buybrokerperson inner join psxcompany on psxcompany.compname = buybrokerperson.compname WHERE((buybrokerperson.sharevalue >=" + shv1 + ") and (buybrokerperson.sharevalue <= " + shv2 + ") and(buybrokerperson.noofshares >= " + n1 + ") and (buybrokerperson.noofshares >= " + n2 + ") and(psxcompany.dividend >= " + r1 + ") and (psxcompany.dividend >= " + r2 + ") )";
            con         = new SqlConnection(connectionString);
            cmd         = new SqlCommand(queryString, con);
            try
            {
                con.Open();
                while (reader.Read())
                {
                    int      noofstocks   = (int)reader["noofshares"];
                    string   compname     = (string)reader["compname"];
                    double   priceofshare = Convert.ToDouble(reader["sharevalue"]);
                    myshares k            = new myshares();
                    k.noofstocks  = noofstocks;
                    k.compname    = compname;
                    k.priceoshare = priceofshare;
                    mm.Add(k);
                }
            }
            catch (SqlException ex)
            {
                Console.WriteLine("SQL Error" + ex.Message.ToString());
                return(null);
            }
            return(mm);
        }