示例#1
0
        public string GetFoodBestSellForMonthAndYear(DateTime dateStart, DateTime dateEnd)
        {
            try
            {
                MY_DB mydb = new MY_DB();

                dateStart.ToShortDateString();
                dateEnd.ToShortDateString();

                SqlCommand command = new SqlCommand("SELECT BillInfo.idFood, COUNT(count) AS number FROM BillInfo,Bill where Bill.id = BillInfo.idBill and DateCheckOut >= '" + dateStart + "' and DateCheckOut <= '" + dateEnd + "' group by BillInfo.idFood ORDER BY number DESC ", mydb.getConnection);

                SqlDataAdapter adap  = new SqlDataAdapter(command);
                DataTable      table = new DataTable();
                adap.Fill(table);
                int            idfood   = Convert.ToInt32(table.Rows[0][0].ToString());
                SqlCommand     command1 = new SqlCommand("SELECT name FROM Food where id=" + idfood, mydb.getConnection);
                SqlDataAdapter adap1    = new SqlDataAdapter(command1);
                DataTable      table1   = new DataTable();
                adap1.Fill(table1);
                string namefood = table1.Rows[0][0].ToString();
                return(namefood);
            }
            catch
            {
                string a = "false";
                return(a);
            }
        }
示例#2
0
        public string GetFoodBestSellForDate(DateTime date)
        {
            try
            {
                MY_DB mydb = new MY_DB();

                //string ngay =
                date.ToShortDateString();

                SqlCommand command = new SqlCommand("SELECT BillInfo.idFood, COUNT(count) AS number FROM BillInfo,Bill where Bill.id = BillInfo.idBill and DateCheckOut = '" + date + "' group by BillInfo.idFood ORDER BY number DESC ", mydb.getConnection);
                //command.Parameters.Add("@date", SqlDbType.NVarChar).Value = ngay;

                SqlDataAdapter adap  = new SqlDataAdapter(command);
                DataTable      table = new DataTable();
                adap.Fill(table);
                int            idfood   = Convert.ToInt32(table.Rows[0][0].ToString());
                SqlCommand     command1 = new SqlCommand("SELECT name FROM Food where id=" + idfood, mydb.getConnection);
                SqlDataAdapter adap1    = new SqlDataAdapter(command1);
                DataTable      table1   = new DataTable();
                adap1.Fill(table1);
                string namefood = table1.Rows[0][0].ToString();
                return(namefood);
            }
            catch
            {
                string a = "false";
                return(a);
            }
        }
示例#3
0
        public DataTable GetAccountNoMember()
        {
            MY_DB          mydb    = new MY_DB();
            SqlCommand     command = new SqlCommand(" SELECT Account.userName FROM Account  EXCEPT SELECT Account.userName FROM Account, Member WHERE Member.username = Account.userName ", mydb.getConnection);
            SqlDataAdapter adap    = new SqlDataAdapter(command);
            DataTable      table   = new DataTable();

            adap.Fill(table);
            return(table);
        }
示例#4
0
        public DataTable getAccount(string username)
        {
            MY_DB      mydb    = new MY_DB();
            SqlCommand command = new SqlCommand("select * from Account where userName=@us", mydb.getConnection);

            command.Parameters.Add("@us", SqlDbType.NVarChar).Value = username;
            SqlDataAdapter adap  = new SqlDataAdapter(command);
            DataTable      table = new DataTable();

            adap.Fill(table);
            return(table);
        }