Example #1
0
        //決定ボタンを押したとき
        private void button1_Click(object sender, EventArgs e)
        {
            timeClass.setDay(new bool[] { checkBox1.Checked, checkBox2.Checked, checkBox3.Checked, checkBox4.Checked, checkBox5.Checked, checkBox6.Checked, checkBox7.Checked });
            for (int i = 0; i < ShareData.rooms.Count; i++)
            {
                if (listView2.Items[i].Selected)
                {
                    timeClass.setRoomName(listView2.Items[i].Text);
                    break;
                }
            }
            for (int i = 0; i < ShareData.timeTables.Count; i++)
            {
                if (listView1.Items[i].Selected)
                {
                    timeClass.setTimeTable(listView1.Items[i].Text);
                    break;
                }
            }
            if (radioButton1.Checked)
            {
                //リストから情環とか選んだものからBeginTimeとEndTimeを取得する
                Console.WriteLine("これが現実だ!" + listView1.SelectedItems[0].Text);
                timeClass.setType(0);
                for (int i = 0; i < ShareData.timeTables.Count; i++)
                {
                    Console.WriteLine(ShareData.timeTables[i].getName());
                    if (listView1.SelectedItems[0].Text == ShareData.timeTables[i].getName())
                    {
                        timeClass.setBeginTime(ShareData.timeTables[i].getBeginTime());
                        timeClass.setEndTime(ShareData.timeTables[i].getEndTime());
                        break;
                    }
                }
            }
            else
            {
                timeClass.setType(1);
                timeClass.setBeginTime(dateTimePicker1.Value);
                timeClass.setEndTime(dateTimePicker2.Value);
            }

            if (ShareData.timeNum != -1)
            {
                //時間を上書き
                UserData.scheduleClasses[ShareData.num].renewTime(timeClass, ShareData.timeNum);
            }
            else
            {
                //時間を追加
                UserData.scheduleClasses[ShareData.num].addTime(timeClass);
            }
            this.Close();
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //リストに同じ名前のものがあるか確認する
            for (int i = 0; i < UserData.scheduleClasses.Count; i++)
            {
                if (UserData.scheduleClasses[i].getName() == textBox1.Text)
                {
                    MessageBox.Show("すでに登録されている名前を新しく登録することはできません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }


            //新規フォルダ作成
            System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(Environment.CurrentDirectory + "\\" + textBox1.Text);

            //ScheduleClass作成
            ScheduleClass schedule = new ScheduleClass();
            TimeClass     time     = new TimeClass();

            schedule.setName(textBox1.Text);
            time.setRoomName(listView2.SelectedItems[0].Text);
            int type = 0;

            if (!radioButton1.Checked)
            {
                type = 1;
            }
            time.setType(type);

            if (type == 0)
            {
                //リストから情環とか選んだものからBeginTimeとEndTimeを取得する
                Console.WriteLine("これが現実だ!" + listView1.SelectedItems[0].Text);
                time.setTimeTable(listView1.SelectedItems[0].Text);
                for (int i = 0; i < ShareData.timeTables.Count; i++)
                {
                    Console.WriteLine(ShareData.timeTables[i].getName());
                    if (listView1.SelectedItems[0].Text == ShareData.timeTables[i].getName())
                    {
                        time.setBeginTime(ShareData.timeTables[i].getBeginTime());
                        time.setEndTime(ShareData.timeTables[i].getEndTime());
                        break;
                    }
                }
            }
            else
            {
                time.setBeginTime(dateTimePicker1.Value);
                time.setEndTime(dateTimePicker2.Value);
            }

            bool[] day = new bool[7];
            day[0] = checkBox1.Checked;
            day[1] = checkBox2.Checked;
            day[2] = checkBox3.Checked;
            day[3] = checkBox4.Checked;
            day[4] = checkBox5.Checked;
            day[5] = checkBox6.Checked;
            day[6] = checkBox7.Checked;
            time.setDay(day);

            schedule.addTime(time);
            UserData.scheduleClasses.Add(schedule);

            this.Close();
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            //ここからサーバー通信
            WebRequest  req = WebRequest.Create(url + "user_id=" + textBox1.Text + "&password="******"UTF-8"));
                String       result = reader.ReadToEnd();
                if (result.Contains("エラー"))
                {
                    MessageBox.Show("入力内容が違います!\nそれかUNIPAメンテナンス",
                                    "エラー",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                //エラーでないなら時間割取得成功!JSONが返ってきているはず
                else
                {
                    var json = (dynamic)JsonConvert.DeserializeObject(result);
                    int num  = 0;
                    //string[] dayofWeek = new string[] { "sun", "mon", "tue", "wed", "thu", "fri", "sat" };
                    //曜日ずつforeach
                    foreach (var day in json)
                    {
                        //Console.WriteLine(day.ToString());
                        foreach (var time in day)
                        {
                            //時限ずつforeach
                            foreach (var element in time)
                            {
                                string TimeName = element["TimeName"];
                                string Name     = element["Name"];

                                TimeClass timeClass = new TimeClass();
                                TimeClass unipa     = new TimeClass();
                                timeClass.setType(1);
                                //TimeTableの特定
                                for (int i = 0; i < ShareData.timeTables.Count; i++)
                                {
                                    TimeTable timeTable = ShareData.timeTables[i];
                                    //もし"J1限"といった文字列が同じだったら
                                    if (TimeName == timeTable.getUnipaName())
                                    {
                                        unipa.setTimeTable(TimeName);
                                        unipa.setBeginTime(timeTable.getBeginTime());
                                        unipa.setEndTime(timeTable.getEndTime());
                                        Console.WriteLine(TimeName + "を登録");
                                        break;
                                    }
                                }


                                //もしないときこうなります
                                if (UserData.scheduleClasses.Count == 0)
                                {
                                    ScheduleClass schedule = new ScheduleClass();

                                    schedule.setName(Name);
                                    timeClass.setTimeTable(TimeName);
                                    timeClass.setBeginTime(unipa.getBeginTime());
                                    timeClass.setEndTime(unipa.getEndTime());
                                    timeClass.setOneDay(true, num);
                                    schedule.addTime(timeClass);
                                    UserData.scheduleClasses.Add(schedule);
                                    Console.WriteLine("はじめましての追加" + schedule.getName() + ShareData.dayofWeek[num]);
                                    //新規フォルダ作成
                                    System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(Environment.CurrentDirectory + "\\" + schedule.getName());
                                    continue;
                                }
                                //すでにスケジュールが入っている場合
                                else
                                {
                                    for (int i = 0; i < UserData.scheduleClasses.Count; i++)
                                    {
                                        ScheduleClass schedule = UserData.scheduleClasses[i];
                                        if (Name == schedule.getName())
                                        {
                                            //開始時間と終了時間が同じなら曜日のみ追加
                                            for (int j = 0; j < schedule.TimeSize(); j++)
                                            {
                                                timeClass = schedule.getTime(j);
                                                //時限が同じだったら"J1限"といった文字列が同じだったらということ
                                                if (timeClass.getTimeTable() == TimeName)
                                                {
                                                    //曜日の登録
                                                    timeClass.setOneDay(true, num);
                                                    UserData.scheduleClasses[i].renewTime(timeClass, j);
                                                    Console.WriteLine("おきかえました" + UserData.scheduleClasses[i].getName() + ShareData.dayofWeek[num]);
                                                    break;
                                                }
                                                else if (j == schedule.TimeSize() - 1)
                                                {
                                                    TimeClass newTime = new TimeClass();
                                                    newTime.setTimeTable(TimeName);
                                                    newTime.setOneDay(true, num);
                                                    newTime.setBeginTime(unipa.getBeginTime());
                                                    newTime.setEndTime(unipa.getEndTime());
                                                    UserData.scheduleClasses[i].addTime(newTime);
                                                    Console.WriteLine(schedule.getName() + "のタイムを追加");
                                                }
                                            }
                                            break;
                                        }
                                        //その授業のスケジュールが追加されていない場合
                                        else if (i == UserData.scheduleClasses.Count - 1)
                                        {
                                            Console.WriteLine("スケジュールの新規追加");
                                            ScheduleClass newSchedule = new ScheduleClass();
                                            TimeClass     newTime     = new TimeClass();
                                            newSchedule.setName(Name);
                                            newTime.setOneDay(true, num);
                                            newTime.setTimeTable(TimeName);
                                            newTime.setBeginTime(unipa.getBeginTime());
                                            newTime.setEndTime(unipa.getEndTime());
                                            newSchedule.addTime(newTime);
                                            UserData.scheduleClasses.Add(newSchedule);
                                            System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(Environment.CurrentDirectory + "\\" + newSchedule.getName());
                                        }
                                    }
                                }
                            }
                        }
                        num++;
                    }
                    //最後にできたという表示をしてウィンドウを閉じる
                    DialogResult message = MessageBox.Show("UNIPAから時間割を追加しました!",
                                                           "正常終了",
                                                           MessageBoxButtons.OK,
                                                           MessageBoxIcon.Information);
                    if (message == DialogResult.Yes)
                    {
                        this.Close();
                    }
                }
                stm.Close();
            }
            rsp.Close();
        }