Beispiel #1
0
        public Server()
        {
            InitializeComponent();

            Thread t = new Thread(InitSocket);

            t.IsBackground = true;
            t.Start();

            //메뉴정보 폴더체크
            DirectoryInfo mmf = new DirectoryInfo(Application.StartupPath + @"\MainMenu");

            if (!mmf.Exists)
            {
                mmf.Create();
            }
            DirectoryInfo smf = new DirectoryInfo(Application.StartupPath + @"\SideMenu");

            if (!smf.Exists)
            {
                smf.Create();
            }
            DirectoryInfo bf = new DirectoryInfo(Application.StartupPath + @"\BeverageMenu");

            if (!bf.Exists)
            {
                bf.Create();
            }

            //각 메뉴별 객체 생성
            mainInfo     = new MenuInfo(mainMenu, mainImg);
            sideInfo     = new MenuInfo(sideMenu, sideImg);
            beverageInfo = new MenuInfo(beverageMenu, beverageImg);

            //메뉴파일이 있다면 불러온다
            MenuManage.MenuLoad(mainInfo, Application.StartupPath + "\\MainMenu\\MainMenu.txt");
            MenuManage.MenuLoad(sideInfo, Application.StartupPath + "\\SideMenu\\SideMenu.txt");
            MenuManage.MenuLoad(beverageInfo, Application.StartupPath + "\\BeverageMenu\\BeverageMenu.txt");

            //사진파일을 불러온다
            replaceImg(mainInfo, Application.StartupPath + "\\MainMenu\\");
            replaceImg(sideInfo, Application.StartupPath + "\\SideMenu\\");
            replaceImg(beverageInfo, Application.StartupPath + "\\BeverageMenu\\");
        }
Beispiel #2
0
        //추가버튼을 눌렸을때
        private void AddMemu_Click(object sender, EventArgs e)
        {
            m_name  = nameBox.Text;
            m_price = priceBox.Text;
            if (imgPath.Text != "")
            {
                if (menuType == 1)
                {
                    main.addMenu(m_name, m_price, imgPath.Text);
                    string fileName = (main.menu.Items.Count - 1).ToString();
                    main.FileCopy(imgPath.Text, Application.StartupPath + "\\MainMenu", fileName);
                    MenuManage.MenuSave(main, Application.StartupPath + "\\MainMenu\\MainMenu.txt");
                }
                else if (menuType == 2)
                {
                    side.addMenu(m_name, m_price, imgPath.Text);
                    string fileName = (side.menu.Items.Count - 1).ToString();
                    side.FileCopy(imgPath.Text, Application.StartupPath + "\\SideMenu", fileName);
                    MenuManage.MenuSave(side, Application.StartupPath + "\\SideMenu\\SideMenu.txt");
                }
                else if (menuType == 3)
                {
                    beverage.addMenu(m_name, m_price, imgPath.Text);
                    string fileName = (beverage.menu.Items.Count - 1).ToString();
                    beverage.FileCopy(imgPath.Text, Application.StartupPath + "\\BeverageMenu", fileName);
                    MenuManage.MenuSave(beverage, Application.StartupPath + "\\BeverageMenu\\BeverageMenu.txt");
                }

                MessageBox.Show("추가되었습니다.");
                imgPath.Text = "";
                this.Close();
            }
            else
            {
                MessageBox.Show("사진을 선택해주세요");
                return;
            }
        }
Beispiel #3
0
        //수정버튼
        private void edit_Click(object sender, EventArgs e)
        {
            m_name  = nameBox.Text;
            m_price = priceBox.Text;

            int indexnum;

            indexnum = listView1.FocusedItem.Index;

            //사진까지 교체할때
            if (imgPath.Text != "")
            {
                if (menuType == 1)
                {
                    main.menu.Items[indexnum].Text = m_name;
                    main.menu.Items[indexnum].Tag  = m_price;
                    FileCopy(imgPath.Text, Application.StartupPath + "\\MainMenu", indexnum.ToString());
                    replaceImg(main, Application.StartupPath + "\\MainMenu\\");
                    MenuManage.MenuSave(main, Application.StartupPath + "\\MainMenu\\MainMenu.txt");

                    listView1.Clear();
                    CopyListView(main.menu, listView1);
                }
                else if (menuType == 2)
                {
                    side.menu.Items[indexnum].Text = m_name;
                    side.menu.Items[indexnum].Tag  = m_price;
                    FileCopy(imgPath.Text, Application.StartupPath + "\\SideMenu", indexnum.ToString());
                    replaceImg(side, Application.StartupPath + "\\SideMenu");
                    MenuManage.MenuSave(side, Application.StartupPath + "\\SideMenu\\SideMenu.txt");

                    listView1.Clear();
                    CopyListView(side.menu, listView1);
                }
                else if (menuType == 3)
                {
                    beverage.menu.Items[indexnum].Text = m_name;
                    beverage.menu.Items[indexnum].Tag  = m_price;
                    FileCopy(imgPath.Text, Application.StartupPath + "\\BeverageMenu", indexnum.ToString());
                    replaceImg(beverage, Application.StartupPath + "\\BeverageMenu");
                    MenuManage.MenuSave(beverage, Application.StartupPath + "\\BeverageMenu\\BeverageMenu.txt");

                    listView1.Clear();
                    CopyListView(beverage.menu, listView1);
                }
                MessageBox.Show("메뉴가 수정되었습니다.");
                imgPath.Text = "";
            }

            //사진을 안넣고 수정했을때
            else
            {
                if (menuType == 1)
                {
                    main.menu.Items[indexnum].Text = m_name;
                    main.menu.Items[indexnum].Tag  = m_price;
                    replaceImg(main, Application.StartupPath + "\\MainMenu\\");
                    MenuManage.MenuSave(main, Application.StartupPath + "\\MainMenu\\MainMenu.txt");

                    listView1.Clear();
                    CopyListView(main.menu, listView1);
                }
                else if (menuType == 2)
                {
                    side.menu.Items[indexnum].Text = m_name;
                    side.menu.Items[indexnum].Tag  = m_price;
                    replaceImg(side, Application.StartupPath + "\\SideMenu");
                    MenuManage.MenuSave(side, Application.StartupPath + "\\SideMenu\\SideMenu.txt");

                    listView1.Clear();
                    CopyListView(side.menu, listView1);
                }
                else if (menuType == 3)
                {
                    beverage.menu.Items[indexnum].Text = m_name;
                    beverage.menu.Items[indexnum].Tag  = m_price;
                    replaceImg(beverage, Application.StartupPath + "\\BeverageMenu");
                    MenuManage.MenuSave(beverage, Application.StartupPath + "\\BeverageMenu\\BeverageMenu.txt");

                    listView1.Clear();
                    CopyListView(beverage.menu, listView1);
                }
                MessageBox.Show("메뉴가 수정되었습니다.");
                imgPath.Text = "";
            }
        }
Beispiel #4
0
        //삭제버튼
        private void delete_Click(object sender, EventArgs e)
        {
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();
            m_name  = nameBox.Text;
            m_price = priceBox.Text;

            int    indexnum;
            string deleteFile;
            string fileExt;

            indexnum = listView1.FocusedItem.Index;

            if (menuType == 1)
            {
                deleteFile = indexnum.ToString();
                main.menu.Items[indexnum].Text = m_name;
                main.menu.Items[indexnum].Tag  = m_price;
                main.menu.Items[indexnum].Remove();

                DirectoryInfo dir   = new DirectoryInfo(Application.StartupPath + "\\MainMenu");
                FileInfo[]    files = dir.GetFiles(indexnum + ".*");
                if (files.Length > 0)
                {
                    fileExt     = files[0].Extension;
                    deleteFile += fileExt;
                    deleteFile  = Path.Combine(Application.StartupPath + "\\MainMenu", deleteFile);
                }
                File.Delete(deleteFile);

                deleteImg(main, Application.StartupPath + "\\MainMenu");
                MenuManage.MenuSave(main, Application.StartupPath + "\\MainMenu\\MainMenu.txt");

                listView1.Clear();
                CopyListView(main.menu, listView1);
            }
            else if (menuType == 2)
            {
                deleteFile = indexnum.ToString();
                side.menu.Items[indexnum].Text = m_name;
                side.menu.Items[indexnum].Tag  = m_price;
                side.menu.Items[indexnum].Remove();

                DirectoryInfo dir   = new DirectoryInfo(Application.StartupPath + "\\SideMenu");
                FileInfo[]    files = dir.GetFiles(indexnum + ".*");
                if (files.Length > 0)
                {
                    fileExt     = files[0].Extension;
                    deleteFile += fileExt;
                    deleteFile  = Path.Combine(Application.StartupPath + "\\SideMenu", deleteFile);
                }
                File.Delete(deleteFile);

                deleteImg(side, Application.StartupPath + "\\SideMenu");
                MenuManage.MenuSave(side, Application.StartupPath + "\\SideMenu\\SideMenu.txt");

                listView1.Clear();
                CopyListView(side.menu, listView1);
            }
            else if (menuType == 3)
            {
                deleteFile = indexnum.ToString();
                beverage.menu.Items[indexnum].Text = m_name;
                beverage.menu.Items[indexnum].Tag  = m_price;
                beverage.menu.Items[indexnum].Remove();

                DirectoryInfo dir   = new DirectoryInfo(Application.StartupPath + "\\BeverageMenu");
                FileInfo[]    files = dir.GetFiles(indexnum + ".*");
                if (files.Length > 0)
                {
                    fileExt     = files[0].Extension;
                    deleteFile += fileExt;
                    deleteFile  = Path.Combine(Application.StartupPath + "\\BeverageMenu", deleteFile);
                }
                File.Delete(deleteFile);

                deleteImg(beverage, Application.StartupPath + "\\BeverageMenu");
                MenuManage.MenuSave(beverage, Application.StartupPath + "\\BeverageMenu\\BeverageMenu.txt");

                listView1.Clear();
                CopyListView(beverage.menu, listView1);
            }
        }