コード例 #1
0
ファイル: MainForm.cs プロジェクト: wee2tee/SN_Net
 private void userInformationToolStripMenuItem_Click(object sender, EventArgs e)
 {
     UsersList wind = new UsersList(this);
     wind.ShowDialog();
 }
コード例 #2
0
        private void btnGo_Click(object sender, EventArgs e)
        {
            this.tableLayoutPanel1.Visible = false;

            DateTime first_date        = DateTime.Parse(this.year.ToString() + "-" + this.month.ToString() + "-1", CultureInfo.GetCultureInfo("th-TH"));
            int      days_in_month     = DateTime.DaysInMonth((this.year - 543), this.month);
            DateTime last_date         = first_date.AddDays(days_in_month - 1);
            int      first_day_of_week = first_date.GetDayIntOfWeek();

            string from_date = DateTime.Parse(this.year.ToString() + "/" + this.month.ToString() + "/1", CultureInfo.GetCultureInfo("th-TH"), DateTimeStyles.None).ToMysqlDate();
            string to_date   = DateTime.Parse(this.year.ToString() + "/" + this.month.ToString() + "/" + days_in_month.ToString(), CultureInfo.GetCultureInfo("th-TH"), DateTimeStyles.None).ToMysqlDate();

            List <EventCalendar>    event_cal;
            List <TrainingCalendar> training_cal;
            List <NoteCalendar>     note_cal;

            CRUDResult   get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "eventcalendar/get_event&from_date=" + from_date + "&to_date=" + to_date);
            ServerResult sr  = JsonConvert.DeserializeObject <ServerResult>(get.data);

            if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
            {
                event_cal    = sr.event_calendar;
                training_cal = sr.training_calendar;
                note_cal     = sr.note_calendar;
            }
            else
            {
                event_cal    = new List <EventCalendar>();
                training_cal = new List <TrainingCalendar>();
                note_cal     = new List <NoteCalendar>();
            }

            List <Istab> absent_cause = IstabWindow.GetIstab(Istab.getTabtypString(Istab.TABTYP.ABSENT_CAUSE));
            List <Users> users_list   = UsersList.GetUsers();

            int increase_date = 0 + ((first_day_of_week - 1) * -1);

            for (int i = 1; i < this.tableLayoutPanel1.RowCount; i++)
            {
                for (int j = 0; j < this.tableLayoutPanel1.ColumnCount; j++)
                {
                    // remove existing control
                    if (this.tableLayoutPanel1.GetControlFromPosition(j, i) != null)
                    {
                        this.tableLayoutPanel1.Controls.Remove(this.tableLayoutPanel1.GetControlFromPosition(j, i));
                    }

                    // create new control
                    NoteCalendar    note        = note_cal.Where(n => n.date == first_date.AddDays(increase_date).ToString("yyyy-MM-dd", CultureInfo.GetCultureInfo("en-US"))).FirstOrDefault();
                    int             max_leave   = note != null ? note.max_leave : -1;
                    List <AbsentVM> absent_list = event_cal.Where(ev => ev.date == first_date.AddDays(increase_date).ToString("yyyy-MM-dd", CultureInfo.GetCultureInfo("en-US"))).ToAbsentViewModel(absent_cause, users_list, max_leave);
                    var             trainer     = training_cal.Where(t => t.date == first_date.AddDays(increase_date).ToString("yyyy-MM-dd", CultureInfo.GetCultureInfo("en-US"))).ToList();
                    //var note = note_cal;

                    CustomDateEvent2 de = new CustomDateEvent2(this.main_form, this, first_date.AddDays(increase_date), this.month, absent_list, absent_cause, trainer, note, users_list, max_leave);
                    this.tableLayoutPanel1.Controls.Add(de, j, i);
                    increase_date++;
                }
            }

            this.tableLayoutPanel1.Visible = true;
        }