Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
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;
            }
        }
Ejemplo n.º 5
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();
 }
Ejemplo n.º 6
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());
            }
        }
Ejemplo n.º 7
0
        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;
            }
        }
Ejemplo n.º 8
0
 //private void UpdateDateEventUI()
 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)
 {
     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]);
 }