Ejemplo n.º 1
0
        public Boolean GetBool()
        {
            MySqlConnection conn = conDB.OpenConnection();

            try
            {
                conn.Open();
                Console.WriteLine("DataBase연동 성공");
                string          sql    = "select * from autologin";
                MySqlCommand    cmd    = new MySqlCommand(sql, conn);
                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    AutoLogin = Convert.ToBoolean((System.SByte)reader["bool"]);
                }
            }
            catch (MySqlException ex)
            {
                switch (ex.Number)
                {
                case 0:
                    Console.WriteLine("데이터베이스 서버에 연결할 수 없습니다.");
                    break;

                case 1045:
                    Console.WriteLine("유저 ID 또는 Password를 확인해주세요.");
                    break;
                }
            }
            finally
            {
                conn.Close();
            }
            return(AutoLogin);
        }
Ejemplo n.º 2
0
        public List <SaleModel> SelectOrderList(string WhereSql)
        {
            MySqlConnection conn = conDB.OpenConnection();

            try
            {
                conn.Open();
                Console.WriteLine("DataBase연동 성공");
                string          sql    = "SELECT * FROM kiosk.order " + WhereSql;
                MySqlCommand    cmd    = new MySqlCommand(sql, conn);
                MySqlDataReader reader = cmd.ExecuteReader();

                List <SaleModel> sales = new List <SaleModel>();
                SaleModel        sale;

                while (reader.Read())
                {
                    sale          = new SaleModel();
                    sale.category = (String)reader["category"];
                    sale.price    = (int)reader["price"];
                    sale.sale     = (int)reader["sale"];
                    sale.count    = (int)reader["count"];

                    sales.Add(sale);
                }

                return(sales);
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex);
                switch (ex.Number)
                {
                case 0:
                    Console.WriteLine("데이터베이스 서버에 연결할 수 없습니다.");
                    break;

                case 1045:
                    Console.WriteLine("유저 ID 또는 Password를 확인해주세요.");
                    break;
                }
            }
            finally
            {
                conn.Close();
            }

            return(null);
        }
Ejemplo n.º 3
0
        public void SetMenuSetting(MenuModel instance)
        {
            MySqlConnection conn = conDB.OpenConnection();

            try
            {
                conn.Open();
                Console.WriteLine("DataBase연동 성공");
                string       sql = "UPDATE " + instance.category + " SET sale =" + instance.sale + " WHERE id = " + instance.id;
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                cmd.ExecuteNonQuery();

                sql = "UPDATE " + instance.category + " SET soldout =" + instance.soldOut + " WHERE id = " + instance.id;
                cmd = new MySqlCommand(sql, conn);
                cmd.ExecuteNonQuery();
            }
            catch (MySqlException ex)
            {
                switch (ex.Number)
                {
                case 0:
                    Console.WriteLine("데이터베이스 서버에 연결할 수 없습니다.");
                    break;

                case 1045:
                    Console.WriteLine("유저 ID 또는 Password를 확인해주세요.");
                    break;
                }
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 4
0
        public List <TableModel> GetTable()
        {
            TableModel        table;
            List <TableModel> list = new List <TableModel>();
            MySqlConnection   conn = conDB.OpenConnection();

            try
            {
                conn.Open();
                Console.WriteLine("DataBase연동 성공");
                string          sql    = "SELECT * FROM kiosk.table;";
                MySqlCommand    cmd    = new MySqlCommand(sql, conn);
                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    table           = new TableModel();
                    table.id        = (int)reader["id"];
                    table.OrderTime = DateTime.Parse((string)reader["OrderTime"]);
                    list.Add(table);
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex);
                switch (ex.Number)
                {
                case 0:
                    Console.WriteLine("데이터베이스 서버에 연결할 수 없습니다.");
                    break;

                case 1045:
                    Console.WriteLine("유저 ID 또는 Password를 확인해주세요.");
                    break;
                }
            }
            finally
            {
                conn.Close();
            }
            return(list);
        }
Ejemplo n.º 5
0
        public List <TimeSpan> GetTime()
        {
            MySqlConnection conn = conDB.OpenConnection();

            try
            {
                conn.Open();
                Console.WriteLine("DataBase연동 성공");
                string          sql    = "select * from energizingtime";
                MySqlCommand    cmd    = new MySqlCommand(sql, conn);
                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    times.Add((TimeSpan)reader["time"]);
                }
            }
            catch (MySqlException ex)
            {
                switch (ex.Number)
                {
                case 0:
                    Console.WriteLine("데이터베이스 서버에 연결할 수 없습니다.");
                    break;

                case 1045:
                    Console.WriteLine("유저 ID 또는 Password를 확인해주세요.");
                    break;
                }
            }
            finally
            {
                conn.Close();
            }

            return(times);
        }
Ejemplo n.º 6
0
        public List <UserModel> GetUser()
        {
            MySqlConnection conn = conDB.OpenConnection();

            try
            {
                conn.Open();
                Console.WriteLine("DataBase연동 성공");
                UserModel       user;
                string          sql    = "select * from kiosk.user";
                MySqlCommand    cmd    = new MySqlCommand(sql, conn);
                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    user         = new UserModel();
                    user.name    = (String)reader["name"];
                    user.barcode = (String)reader["barcode"];

                    users.Add(user);
                }
            }
            catch (MySqlException ex)
            {
                switch (ex.Number)
                {
                case 0:
                    Console.WriteLine("데이터베이스 서버에 연결할 수 없습니다.");
                    break;

                case 1045:
                    Console.WriteLine("유저 ID 또는 Password를 확인해주세요.");
                    break;
                }
            }
            finally
            {
                conn.Close();
            }
            return(users);
        }
Ejemplo n.º 7
0
        public bool GetUserName(String barcode)
        {
            MySqlConnection conn       = conDB.OpenConnection();
            bool            returnType = false;

            try
            {
                conn.Open();
                Console.WriteLine("DataBase연동 성공");
                string          sql    = "SELECT * FROM user WHERE barcode=\"" + barcode + "\"";
                MySqlCommand    cmd    = new MySqlCommand(sql, conn);
                MySqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    App.userData.name = (string)reader["name"];
                    returnType        = true;
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex);
                switch (ex.Number)
                {
                case 0:
                    Console.WriteLine("데이터베이스 서버에 연결할 수 없습니다.");
                    break;

                case 1045:
                    Console.WriteLine("유저 ID 또는 Password를 확인해주세요.");
                    break;
                }
            }
            finally
            {
                conn.Close();
            }
            return(returnType);
        }
Ejemplo n.º 8
0
        public bool SetOrderData(int orderIdx, string day, string time)
        {
            MySqlConnection conn       = conDB.OpenConnection();
            bool            returnType = false;

            try
            {
                conn.Open();
                Console.WriteLine("DataBase연동 성공");
                string sql = string.Format($"INSERT INTO  kiosk.order(`menu`, `category`, `user`, `day`, `price`, `seat`, `sale`, `payment_method`, `time`, `count`) VALUES (" +
                                           $"'{OrderModel.GetInstance()[orderIdx].Name}', '{OrderModel.GetInstance()[orderIdx].category}', '{App.userData.barcode}', '{day}', " +
                                           $"{OrderModel.GetInstance()[orderIdx].Price}, {App.userData.seat}, {OrderModel.GetInstance()[orderIdx].sale}, '{App.userData.payment}','{time}', " +
                                           $"{OrderModel.GetInstance()[orderIdx].Count});");
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                cmd.ExecuteNonQuery();
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex);
                switch (ex.Number)
                {
                case 0:
                    Console.WriteLine("데이터베이스 서버에 연결할 수 없습니다.");
                    break;

                case 1045:
                    Console.WriteLine("유저 ID 또는 Password를 확인해주세요.");
                    break;
                }
            }
            finally
            {
                conn.Close();
            }
            return(returnType);
        }