Ejemplo n.º 1
0
        public void Execute(object parameter)
        {
            ItemViewPage  itemViewPage = parameter as ItemViewPage;
            ItemViewModel vm           = itemViewPage.Resources["ItemVM"] as ItemViewModel;
            AddItemPopup  popup        = new AddItemPopup();

            popup.Resources["ItemVM"] = vm;
            vm.IsItemPopup            = true;
            ItemPopupViewModel popUpVM = popup.Resources["PopUpVM"] as ItemPopupViewModel;
            ItemModel          model   = new ItemModel();

            popUpVM.Shop_Name = model.Shop_Name;
            popUpVM.Memo      = model.Memo;
            popUpVM.Name      = model.Name;
            popUpVM.Link      = model.Link;
            popUpVM.Item_ID   = model.Item_ID;
            popUpVM.Price     = model.Price;
            if (model.Liked == 1)
            {
                popUpVM.Liked = true;
            }
            else
            {
                popUpVM.Liked = false;
            }
            popUpVM.Temp     = model.Temp;
            popUpVM.Image    = model.Image;
            popUpVM.Category = model.Category;
            popup.Show();
        }
Ejemplo n.º 2
0
        public void Execute(object parameter)
        {
            MainWindow    window = parameter as MainWindow;
            MainViewModel MainVM = window.Resources["MainVM"] as MainViewModel;

            // 페이지 변경
            // 룩북 뷰 <---> 아이템 뷰
            if (window.Mainframe.Content.GetType() == typeof(LookBookPage) || window.Mainframe.Content.GetType() == typeof(SearchViewPage))
            {
                // itemView 처리
                ItemViewPage  itemView = new ItemViewPage();
                ItemViewModel itemVM   = itemView.Resources["ItemVM"] as ItemViewModel;
                MainVM.itemVM       = itemVM;
                itemVM.itemViewPage = itemView;
                itemVM.setUser(MainVM.user);
                itemVM.setItemlist();
                string temp_str = (window.Resources["WeatherAPI"] as WeatherAPI).T3H;
                int    temp     = int.Parse(temp_str.Replace("°", ""));
                itemVM.Temp = temp;
                itemVM.updateWeatherRecommands(temp);
                if (itemVM.recommandsList.Count() > 4)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        itemVM.recommand_four.Add(itemVM.recommandsList[i]);
                        itemVM.recommand_four[i].x = i;
                    }
                }
                else
                {
                    for (int i = 0; i < itemVM.recommandsList.Count(); i++)
                    {
                        itemVM.recommand_four.Add(itemVM.recommandsList[i]);
                        itemVM.recommand_four[i].x = i;
                    }
                }
                itemView.itemListView.ItemsSource      = itemVM.items;
                itemView.recommandListView.ItemsSource = itemVM.recommand_four;
                window.Mainframe.Navigate(itemView);
            }
            else if (window.Mainframe.Content.GetType() == typeof(ItemViewPage) || window.Mainframe.Content.GetType() == typeof(SearchViewPage))
            {
                // lookbookView 처리
                LookBookPage      lookBookView = new LookBookPage();
                LookBookViewModel lookBookVM   = lookBookView.Resources["lookBookVM"] as LookBookViewModel;
                MainVM.lookBookVM = lookBookVM;
                lookBookVM.setUser(MainVM.user);
                lookBookVM.setLookBookList();
                lookBookView.LookBookListView.ItemsSource = lookBookVM.lookBookItems;
                window.Mainframe.Navigate(lookBookView);
            }
        }
 public ItemID_ItemPage_Class(object id, object vp)
 {
     ItemID        = (int)id;
     _ItemViewPage = vp as ItemViewPage;
 }
 public ItemID_ItemPage_Class(int id, ItemViewPage vp)
 {
     ItemID        = id;
     _ItemViewPage = vp;
 }
Ejemplo n.º 5
0
        public void Execute(object parameter)
        {
            LoginWindow window = parameter as LoginWindow;

            try
            {
                MainWindow mainWindow;
                User       user;

                // ssh 접속
                using (var client = new SshClient("106.10.57.242", 5000, "root", "qawzsx351"))
                {
                    client.Connect();
                    if (client.IsConnected)
                    {
                        try
                        {
                            // 내부 db 접속을 위한 포트포워딩
                            var portForwarded = new ForwardedPortLocal("127.0.0.1", 3306, "127.0.0.1", 3306);
                            client.AddForwardedPort(portForwarded);
                            portForwarded.Start();

                            // db 접속
                            using (MySqlConnection con = new MySqlConnection("SERVER=localhost;PORT=3306;UID=root;PASSWORD=qawzsx351;DATABASE=codibook;SslMode=None"))
                            {
                                con.Open();
                                if (window.ID_BOX.Text.Equals(string.Empty) || window.ID_BOX.Text.Length <= 5)
                                {
                                    MessageBox.Show("id는 6글자 이상이어야 햡니다.");
                                    return;
                                }
                                if (window.Password_BOX.Password.Equals(string.Empty) || window.Password_BOX.Password.Length <= 7)
                                {
                                    MessageBox.Show("password는 8글자 이상이어야 햡니다.");
                                    return;
                                }
                                if (!CheckEnglish(window.ID_BOX.Text))
                                {
                                    MessageBox.Show("id에는 영어가 포함되어야 합니다.");
                                    return;
                                }
                                user = new User(window.ID_BOX.Text, (window.Password_BOX.Password.GetHashCode() & 0x7fffffff).ToString(), "", "");
                                string       query1 = "SELECT COUNT(*) FROM user WHERE ID='" + window.ID_BOX.Text + "' AND PASSWORD='******'";
                                MySqlCommand sqlCom = new MySqlCommand(query1, con);
                                if (sqlCom.ExecuteScalar().ToString().Equals("1"))
                                {
                                    string          query2  = "SELECT * FROM user WHERE ID='" + window.ID_BOX.Text + "' AND PASSWORD='******'";
                                    MySqlCommand    sqlCom2 = new MySqlCommand(query2, con);
                                    MySqlDataReader reader  = sqlCom2.ExecuteReader();
                                    while (reader.Read())
                                    {
                                        user.User_ID = ((int)reader["USER_ID"]).ToString();
                                        user.Time    = reader["TIME"] as string;
                                    }
                                    con.Close();
                                    client.Disconnect();
                                    mainWindow = new MainWindow();
                                    MainViewModel MainVM = mainWindow.Resources["MainVM"] as MainViewModel;
                                    MainVM.user = user;

                                    // 뷰페이지 데이터 db에서 받아오기
                                    ItemViewPage  itemView = new ItemViewPage();
                                    ItemViewModel vm       = itemView.Resources["ItemVM"] as ItemViewModel;
                                    MainVM.itemVM   = vm;
                                    vm.itemViewPage = itemView;
                                    vm.setUser(user);
                                    vm.setItemlist();
                                    string temp_str = (mainWindow.Resources["WeatherAPI"] as WeatherAPI).T3H;
                                    int    temp     = int.Parse(temp_str.Replace("°", ""));
                                    vm.Temp = temp;
                                    vm.updateWeatherRecommands(temp);
                                    if (vm.recommandsList.Count() > 4)
                                    {
                                        for (int i = 0; i < 4; i++)
                                        {
                                            vm.recommand_four.Add(vm.recommandsList[i]);
                                            vm.recommand_four[i].x = i;
                                        }
                                    }
                                    else
                                    {
                                        for (int i = 0; i < vm.recommandsList.Count(); i++)
                                        {
                                            vm.recommand_four.Add(vm.recommandsList[i]);
                                            vm.recommand_four[i].x = i;
                                        }
                                    }
                                    itemView.itemListView.ItemsSource      = vm.items;
                                    itemView.recommandListView.ItemsSource = vm.recommand_four;

                                    // 프레임 네비게이션
                                    mainWindow.Mainframe.Navigate(itemView);
                                    mainWindow.Show();
                                    window.Close();
                                }
                                else
                                {
                                    MessageBox.Show("로그인 정보가 잘못되었습니다.");
                                    return;
                                }

                                con.Close();
                                client.Disconnect();
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Client cannot be reached...");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 6
0
        public void Execute(object parameter)
        {
            LoginWindow window = parameter as LoginWindow;


            try
            {
                // ssh 접속
                using (var client = new SshClient("106.10.57.242", 5000, "root", "qawzsx351"))
                {
                    client.Connect();
                    if (client.IsConnected)
                    {
                        try
                        {
                            // 내부 db 접속을 위한 포트포워딩
                            var portForwarded = new ForwardedPortLocal("127.0.0.1", 3306, "127.0.0.1", 3306);
                            client.AddForwardedPort(portForwarded);
                            portForwarded.Start();

                            // db 접속
                            using (MySqlConnection con = new MySqlConnection("SERVER=localhost;PORT=3306;UID=root;PASSWORD=qawzsx351;DATABASE=codibook;SslMode=None"))
                            {
                                con.Open();

                                string       query1        = "SELECT COUNT(*) FROM user WHERE ID='" + window.ID_BOX.Text + "'";
                                MySqlCommand sqlCom        = new MySqlCommand(query1, con);
                                object       query1_result = sqlCom.ExecuteScalar();
                                if (int.Parse(query1_result.ToString()) != 0)
                                {
                                    MessageBox.Show("이미 존재하는 id입니다.");
                                    return;
                                }

                                if (window.ID_BOX.Text.Equals(string.Empty) || window.ID_BOX.Text.Length <= 5)
                                {
                                    MessageBox.Show("id는 6글자 이상이어야 햡니다.");
                                    return;
                                }
                                else if (!CheckEnglish(window.ID_BOX.Text))
                                {
                                    MessageBox.Show("id는 6글자 이상이어야 햡니다.");
                                    return;
                                }
                                if (window.Password_BOX.Password.Equals(string.Empty) || window.Password_BOX.Password.Length <= 7)
                                {
                                    MessageBox.Show("password는 8글자 이상이어야 햡니다.");
                                    return;
                                }
                                // 조건에 어긋나지 않으면 새로운 유저 객체를 만들어서 그 값을 서버에 저장한다.
                                User   user   = new User(window.ID_BOX.Text, window.Password_BOX.Password);
                                string query2 = "INSERT INTO user VALUE (" + user.User_ID + ", '" + user.ID + "', '" + user.Password + "', '" + user.Time + "');";
                                sqlCom = new MySqlCommand(query2, con);
                                sqlCom.ExecuteNonQuery();
                                con.Close();
                                client.Disconnect();
                                MainWindow    mainWindow = new MainWindow();
                                MainViewModel MainVM     = mainWindow.Resources["MainVM"] as MainViewModel;
                                MainVM.user = user;

                                // 뷰페이지 데이터 db에서 받아오기
                                ItemViewPage  itemView = new ItemViewPage();
                                ItemViewModel vm       = itemView.Resources["ItemVM"] as ItemViewModel;
                                MainVM.itemVM   = vm;
                                vm.itemViewPage = itemView;
                                vm.setUser(user);
                                vm.setItemlist();
                                string temp_str = (mainWindow.Resources["WeatherAPI"] as WeatherAPI).T3H;
                                int    temp     = int.Parse(temp_str.Replace("°", ""));
                                vm.Temp = temp;
                                vm.updateWeatherRecommands(temp);
                                if (vm.recommandsList.Count() > 4)
                                {
                                    for (int i = 0; i < 4; i++)
                                    {
                                        vm.recommand_four.Add(vm.recommandsList[i]);
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < vm.recommandsList.Count(); i++)
                                    {
                                        vm.recommand_four.Add(vm.recommandsList[i]);
                                    }
                                }
                                itemView.itemListView.ItemsSource      = vm.items;
                                itemView.recommandListView.ItemsSource = vm.recommand_four;

                                // 프레임 네비게이션
                                mainWindow.Mainframe.Navigate(itemView);
                                mainWindow.Show();
                                window.Close();
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Client cannot be reached...");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }