コード例 #1
0
        public static bool CreateHolidayNote(NoteCalendar note)
        {
            string url         = PreferenceForm.API_MAIN_URL() + "notecalendar/create_holiday_note";
            string json_string = "{\"date\":\"" + note.date + "\",";

            json_string += "\"type\":" + note.type.ToString() + ",";
            json_string += "\"description\":\"" + note.description + "\",";
            json_string += "\"group_maid\":\"" + note.group_maid + "\",";
            json_string += "\"group_weekend\":\"" + note.group_weekend + "\",";
            json_string += "\"max_leave\":" + note.max_leave.ToString() + ",";
            json_string += "\"rec_by\":\"" + note.rec_by + "\"}";

            CRUDResult   get = ApiActions.POST(url, json_string);
            ServerResult sr  = JsonConvert.DeserializeObject <ServerResult>(get.data);

            if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
            {
                return(true);
            }
            else if (sr.result == ServerResult.SERVER_CREATE_RESULT_FAILED_EXIST)
            {
                MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                return(false);
            }
            else
            {
                if (MessageAlert.Show(sr.message, "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry)
                {
                    return(CreateHolidayNote(note));
                }

                return(false);
            }
        }
コード例 #2
0
        public YearlyHolidayAddEditDialog(MainForm main_form, NoteCalendar note_calendar = null)
        {
            InitializeComponent();
            this.main_form = main_form;


            if (note_calendar == null)
            {
                this.note_calendar = new NoteCalendar
                {
                    date          = DateTime.Now.ToString("yyyy-MM-dd", CultureInfo.GetCultureInfo("en-US")),
                    description   = string.Empty,
                    max_leave     = -1,
                    rec_by        = this.main_form.G.loged_in_user_name,
                    type          = (int)NoteCalendar.NOTE_TYPE.HOLIDAY,
                    group_maid    = string.Empty,
                    group_weekend = string.Empty
                };
            }
            else
            {
                this.note_calendar        = note_calendar;
                this.note_calendar.rec_by = this.main_form.G.loged_in_user_name;
            }

            this.form_mode = note_calendar != null ? FORM_MODE.EDIT : FORM_MODE.ADD;
        }
コード例 #3
0
        public void RefreshData()
        {
            CRUDResult   get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "eventcalendar/get_event&from_date=" + this.date.Value.ToMysqlDate() + "&to_date=" + this.date.Value.ToMysqlDate());
            ServerResult sr  = JsonConvert.DeserializeObject <ServerResult>(get.data);

            if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
            {
                this.absent_list  = sr.event_calendar.ToAbsentViewModel(this.absent_cause, this.users_list, this.max_leave);
                this.trainer_list = sr.training_calendar;
                this.note         = sr.note_calendar.Where(t => t.date == this.date.Value.ToMysqlDate()).FirstOrDefault();
            }
        }
コード例 #4
0
        public void RefreshData()
        {
            CRUDResult   get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "eventcalendar/get_event&from_date=" + this.date.ToMysqlDate() + "&to_date=" + this.date.ToMysqlDate());
            ServerResult sr  = JsonConvert.DeserializeObject <ServerResult>(get.data);

            if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
            {
                this.event_list    = sr.event_calendar;
                this.training_list = sr.training_calendar;
                this.note_calendar = sr.note_calendar.Find(t => t.date == this.date.ToMysqlDate());
            }
        }
コード例 #5
0
 public CustomDateEvent2(MainForm main_form, Calendar2 calendar, DateTime date, int current_month, List <AbsentVM> absent_list, List <Istab> absent_cause, List <TrainingCalendar> trainer_list, NoteCalendar note, List <Users> users_list, int max_leave)
 {
     //Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
     InitializeComponent();
     this.main_form     = main_form;
     this.date          = date;
     this.current_month = current_month;
     this.absent_list   = absent_list;
     this.absent_cause  = absent_cause;
     this.trainer_list  = trainer_list;
     this.note          = note;
     this.users_list    = users_list;
     this.max_leave     = max_leave;
     this.calendar      = calendar;
 }
コード例 #6
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            NoteCalendar note_calendar = (NoteCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Cells["colNoteCalendar"].Value;

            note_calendar.rec_by = this.main_form.G.loged_in_user_name;
            if (MessageAlert.Show("ลบวันที่ " + note_calendar._Date.ToString("d MMM yy", CultureInfo.GetCultureInfo("th-TH")) + " ออกจากว้นหยุดประจำปี, ทำต่อหรือไม่?", "", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.QUESTION) == DialogResult.OK)
            {
                if (DeleteHolidayNote(note_calendar) == true)
                {
                    this.bs.ResetBindings(true);
                    this.bs.DataSource = GetNoteCalendarList(this.current_year).ToHolidayViewModel();
                    this.calendar.RefreshAtDate(note_calendar._Date);
                }
            }
        }
コード例 #7
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            NoteCalendar note_calendar           = (NoteCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Cells["colNoteCalendar"].Value;
            YearlyHolidayAddEditDialog edit_form = new YearlyHolidayAddEditDialog(this.main_form, note_calendar);

            if (edit_form.ShowDialog() == DialogResult.OK)
            {
                if (UpdateHolidayNote(edit_form.note_calendar) == true)
                {
                    this.bs.ResetBindings(true);
                    this.bs.DataSource = GetNoteCalendarList(this.current_year).ToHolidayViewModel();
                    this.calendar.RefreshAtDate(edit_form.note_calendar._Date);
                }
            }
        }
コード例 #8
0
        public static bool DeleteHolidayNote(NoteCalendar note)
        {
            string       url = PreferenceForm.API_MAIN_URL() + "notecalendar/delete_holiday_note&id=" + note.id.ToString() + "&rec_by=" + note.rec_by;
            CRUDResult   get = ApiActions.DELETE(url);
            ServerResult sr  = JsonConvert.DeserializeObject <ServerResult>(get.data);

            if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
            {
                return(true);
            }
            else
            {
                if (MessageAlert.Show(sr.message, "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry)
                {
                    return(DeleteHolidayNote(note));
                }

                return(false);
            }
        }
コード例 #9
0
        public void RefreshView(List <Users> list_users, List <EventCalendar> list_event_calendar, List <TrainingCalendar> list_training_calendar, NoteCalendar note_calendar, int curr_month)
        {
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += delegate
            {
                this.list_users    = list_users;
                this.event_list    = list_event_calendar;
                this.training_list = list_training_calendar;
                this.note_calendar = note_calendar;
                this.target_month  = curr_month;
                delegateRefreshView del = new delegateRefreshView(this.RefreshView);
                this.Invoke(del);
            };
            worker.RunWorkerCompleted += delegate
            {
                // Do nothing.
            };
            worker.RunWorkerAsync();
        }
コード例 #10
0
ファイル: CustomLabel.cs プロジェクト: wee2tee/SN_Net_V1.1
        public void SetVisualControl(NoteCalendar note_calendar = null, List <TrainingCalendar> training_list = null)
        {
            this.note_calendar = note_calendar;
            this.training_list = training_list;

            if (this.note_calendar != null)
            {
                if (this.note_calendar.group_maid.Trim().Length > 0)
                {
                    this.picMaid.Visible = true;
                    this.lblMaid.Visible = true;
                    this.lblMaid.Text    = note_calendar.group_maid;
                    //this.lblMaid.Click += delegate
                    //{

                    //};
                }
                else
                {
                    this.picMaid.Visible = false;
                    this.lblMaid.Text    = "";
                }

                if (this.note_calendar.group_weekend.Trim().Length > 0)
                {
                    this.picWeekend.Visible = true;
                    this.lblWeekend.Visible = true;
                    this.lblWeekend.Text    = note_calendar.group_weekend;
                    //this.lblWeekend.Click += delegate
                    //{

                    //};
                }
                else
                {
                    this.picWeekend.Visible = false;
                    this.lblWeekend.Text    = "";
                }
            }
            else
            {
                this.picMaid.Visible    = false;
                this.picWeekend.Visible = false;
                this.lblMaid.Visible    = false;
                this.lblWeekend.Visible = false;
            }

            if (this.training_list != null)
            {
                this.lblTrainer.Visible = true;
                string trainer = (this.training_list.Count > 0 ? "อบรม(" : "");

                int trainer_count = 0;
                foreach (TrainingCalendar t in this.training_list)
                {
                    CRUDResult   get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "users/get_realname&username="******"," + sr.users[0].name);
                    }
                    else
                    {
                        trainer += "";
                    }
                }
                trainer += (this.training_list.Count > 0 ? ")" : "");

                this.lblTrainer.Text = trainer;
            }
            else
            {
                this.lblTrainer.Visible = false;
            }
        }
コード例 #11
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;
        }
コード例 #12
0
ファイル: CalendarWindow.cs プロジェクト: wee2tee/SN_Net_V1.1
 private void UpdateDateEventUI(CustomDateEvent de, List <Users> list_users, List <EventCalendar> list_event_calendar, List <TrainingCalendar> list_training_calendar, NoteCalendar note_calendar, int current_month)
 //private void UpdateDateEventUI()
 {
     de.list_users = list_users;
     de.SetEventList(list_event_calendar);
     de.SetTrainingList(list_training_calendar);
     de.note_calendar = note_calendar;
     de.TargetMonth   = current_month;
     de.RefreshView();
     //Console.WriteLine(list_users[0]);
 }