Esempio n. 1
0
 private void ClearInlineForm()
 {
     if (this.inline_user != null)
     {
         this.inline_user.Dispose();
         this.inline_user = null;
     }
 }
Esempio n. 2
0
        private void ShowInlineForm(FORM_MODE mode)
        {
            if (this.current_group != null)
            {
                this.inline_user = new CustomComboBox();
                this.inline_user.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
                this.inline_user.comboBox1.Font = new Font("tahoma", 9.75f);
                this.inline_user.label1.Font = new Font("tahoma", 9.75f);
                this.inline_user.BorderStyle = BorderStyle.None;
                this.inline_user.Read_Only = false;
                this.inline_user.comboBox1.GotFocus += new EventHandler(this.SetControlFocused);
                this.RefreshCurrentData();
                this.FillForm(this.current_group);
                foreach (Users u in this.list_users.Where(u => u.usergroup == string.Empty).ToList<Users>())
                {
                    this.inline_user.AddItem(new ComboboxItem(u.username + " : " + u.name, u.id, u.username) { Tag = u });
                }

                if (mode == FORM_MODE.ADD_F8)
                {
                    this.dgvMember.Rows[this.list_users.Where(u => u.usergroup == this.current_group.typcod).ToList<Users>().Count].Cells[0].Selected = true;
                    this.SetInlineFormPosition();
                }

                this.dgvMember.Parent.Controls.Add(this.inline_user);
                this.dgvMember.SendToBack();
                this.inline_user.BringToFront();
                this.inline_user.comboBox1.Focus();
                SendKeys.Send("{F4}");
            }
            else
            {
                MessageAlert.Show("ท่านต้องสร้างกลุ่มขึ้นมาก่อนที่เพิ่มสมาชิกในกลุ่ม", "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
            }
        }
Esempio n. 3
0
 private void ClearInlineForm()
 {
     if (this.inline_course_type != null)
     {
         this.inline_course_type.Dispose();
         this.inline_course_type = null;
     }
     if (this.inline_trainer != null)
     {
         this.inline_trainer.Dispose();
         this.inline_trainer = null;
     }
     if (this.inline_status != null)
     {
         this.inline_status.Dispose();
         this.inline_status = null;
     }
     if (this.inline_term != null)
     {
         this.inline_term.Dispose();
         this.inline_term = null;
     }
     if (this.inline_remark != null)
     {
         this.inline_remark.Dispose();
         this.inline_remark = null;
     }
 }
Esempio n. 4
0
        private void ShowInlineForm(FORM_MODE mode)
        {
            if (mode == FORM_MODE.ADD_F8)
                this.dgvTrainer.Rows[this.list_training_calendar.Where(t => t.date == this.current_event_date.ToMysqlDate()).Count<TrainingCalendar>()].Cells[0].Selected = true;

            List<Users> rest_users = this.list_trainer_rest.ConvertAll(t => t).ToList<Users>();
            if (mode == FORM_MODE.EDIT_F8)
            {
                rest_users.Add(this.list_trainer_all.Find(u => u.username == ((TrainingCalendar)this.dgvTrainer.Rows[this.dgvTrainer.CurrentCell.RowIndex].Tag).trainer));
                rest_users = rest_users.OrderBy(t => t.username).ToList<Users>();
            }
            this.inline_course_type = (this.inline_course_type == null ? new CustomComboBox() { Read_Only = false, BorderStyle = BorderStyle.None } : this.inline_course_type);
            this.inline_course_type.comboBox1.Items.Clear();
            this.inline_course_type.AddItem(new ComboboxItem("Basic", 1, "Basic"));
            this.inline_course_type.AddItem(new ComboboxItem("Advanced", 2, "Advanced"));
            this.inline_course_type.comboBox1.SelectedIndex = 0;
            this.inline_trainer = (this.inline_trainer == null ? new CustomComboBox() { Read_Only = false, BorderStyle = BorderStyle.None } : this.inline_trainer);
            this.inline_trainer.comboBox1.DropDownStyle = ComboBoxStyle.DropDown;
            this.inline_trainer.comboBox1.Items.Clear();
            //foreach (Users u in rest_users)
            foreach (Users u in this.list_trainer_all)
            {
                this.inline_trainer.AddItem(new ComboboxItem(u.username + " : " + u.name, u.id, u.username) { Tag = u });
            }
            this.inline_trainer.comboBox1.Leave += delegate
            {
                ComboBox cb = this.inline_trainer.comboBox1;
                if (cb.Items.Cast<ComboboxItem>().Where(i => i.ToString().Length >= cb.Text.Length).Where(i => i.ToString().Substring(0, cb.Text.Length) == cb.Text).Count<ComboboxItem>() > 0)
                {
                    cb.SelectedItem = cb.Items.Cast<ComboboxItem>().Where(i => i.ToString().Length >= cb.Text.Length).Where(i => i.ToString().Substring(0, cb.Text.Length) == cb.Text).First<ComboboxItem>();
                }
                else
                {
                    cb.Focus();
                }
            };

            this.inline_status = (this.inline_status == null ? new CustomComboBox() { Read_Only = false, BorderStyle = BorderStyle.None } : this.inline_status);
            this.inline_status.comboBox1.Items.Clear();
            this.inline_status.AddItem(new ComboboxItem("วิทยากร", (int)TRAINER_STATUS.TRAINER, "TRAINER"));
            this.inline_status.AddItem(new ComboboxItem("ผู้ช่วย", (int)TRAINER_STATUS.ASSIST, "ASSISTANT"));
            this.inline_status.comboBox1.SelectedIndex = 0;
            this.inline_term = (this.inline_term == null ? new CustomComboBox() { Read_Only = false, BorderStyle = BorderStyle.None } : this.inline_term);
            this.inline_term.comboBox1.Items.Clear();
            this.inline_term.AddItem(new ComboboxItem("เช้า", (int)TRAINING_TERM.AM, "AM"));
            this.inline_term.AddItem(new ComboboxItem("บ่าย", (int)TRAINING_TERM.PM, "PM"));
            this.inline_term.comboBox1.SelectedIndex = 0;
            this.inline_remark = (this.inline_remark == null ? new CustomTextBox() { Read_Only = false, BorderStyle = BorderStyle.None } : this.inline_remark);

            #region binding inline control event handler
            this.inline_course_type.comboBox1.GotFocus += new EventHandler(this.InlineControlGotFocus);
            this.inline_trainer.comboBox1.GotFocus += new EventHandler(this.InlineControlGotFocus);
            this.inline_status.comboBox1.GotFocus += new EventHandler(this.InlineControlGotFocus);
            this.inline_term.comboBox1.GotFocus += new EventHandler(this.InlineControlGotFocus);
            this.inline_remark.textBox1.GotFocus += new EventHandler(this.InlineControlGotFocus);
            #endregion binding inline control event handler

            if (mode == FORM_MODE.ADD_F8)
            {
                this.FormAddF8();
            }
            else if (mode == FORM_MODE.EDIT_F8)
            {
                this.FormEditF8();
                TrainingCalendar trainer = (TrainingCalendar)this.dgvTrainer.Rows[this.dgvTrainer.CurrentCell.RowIndex].Tag;
                this.inline_course_type.comboBox1.SelectedItem = (this.inline_course_type.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.int_value == trainer.course_type).Count<ComboboxItem>() > 0 ? this.inline_course_type.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.int_value == trainer.course_type).First<ComboboxItem>() : null);
                this.inline_trainer.comboBox1.SelectedItem = (this.inline_trainer.comboBox1.Items.Cast<ComboboxItem>().Where(i => ((Users)i.Tag).username == trainer.trainer).Count<ComboboxItem>() > 0 ? this.inline_trainer.comboBox1.Items.Cast<ComboboxItem>().Where(i => ((Users)i.Tag).username == trainer.trainer).First<ComboboxItem>() : null);
                this.inline_status.comboBox1.SelectedItem = (this.inline_status.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.int_value == trainer.status).Count<ComboboxItem>() > 0 ? this.inline_status.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.int_value == trainer.status).First<ComboboxItem>() : null);
                this.inline_term.comboBox1.SelectedItem = (this.inline_term.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.int_value == trainer.term).Count<ComboboxItem>() > 0 ? this.inline_term.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.int_value == trainer.term).First<ComboboxItem>() : null);
                this.inline_remark.Texts = trainer.remark;
            }
            this.SetInlineFormPosition();
            this.inline_course_type.comboBox1.Focus();

            this.dgvTrainer.Parent.Controls.Add(this.inline_course_type);
            this.dgvTrainer.Parent.Controls.Add(this.inline_trainer);
            this.dgvTrainer.Parent.Controls.Add(this.inline_status);
            this.dgvTrainer.Parent.Controls.Add(this.inline_term);
            this.dgvTrainer.Parent.Controls.Add(this.inline_remark);

            this.dgvTrainer.SendToBack();
            this.inline_course_type.BringToFront();
            this.inline_trainer.BringToFront();
            this.inline_status.BringToFront();
            this.inline_term.BringToFront();
            this.inline_remark.BringToFront();

            this.inline_course_type.Focus();
        }
Esempio n. 5
0
        private void ShowInlineForm()
        {
            int row_index = this.dgv.CurrentCell.RowIndex;

            CustomComboBox inline_users_name = new CustomComboBox();
            inline_users_name.Name = "inline_users_name";
            inline_users_name.comboBox1.DropDownStyle = ComboBoxStyle.DropDown;
            inline_users_name.Read_Only = false;
            inline_users_name.BorderStyle = BorderStyle.None;
            foreach (Users u in this.users_list)
            {
                ComboboxItem item = new ComboboxItem(u.username + " : " + u.name, u.id, u.username);
                inline_users_name.AddItem(item);
                if (this.form_mode == FORM_MODE.EDIT_ITEM)
                {
                    if (u.username == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).users_name)
                    {
                        inline_users_name.comboBox1.SelectedItem = item;
                    }
                }
            }
            inline_users_name.Leave += delegate
            {
                if (inline_users_name.comboBox1.Items.Cast<ComboboxItem>().Where(t => t.name.Length >= inline_users_name.comboBox1.Text.Length).Where(t => t.name.Substring(0, inline_users_name.comboBox1.Text.Length) == inline_users_name.comboBox1.Text).Count() > 0)
                {
                    inline_users_name.comboBox1.SelectedItem = inline_users_name.comboBox1.Items.Cast<ComboboxItem>().Where(t => t.name.Length >= inline_users_name.comboBox1.Text.Length).Where(t => t.name.Substring(0, inline_users_name.comboBox1.Text.Length) == inline_users_name.comboBox1.Text).First();
                }
                else
                {
                    inline_users_name.comboBox1.Focus();
                    SendKeys.Send("{F6}");
                }
            };
            inline_users_name.comboBox1.SelectedIndex = (this.form_mode == FORM_MODE.EDIT_ITEM ? this.users_list.FindIndex(t => t.username == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).users_name) : 0);
            this.dgv.Parent.Controls.Add(inline_users_name);

            CustomComboBox inline_leave_cause = new CustomComboBox();
            inline_leave_cause.Name = "inline_leave_cause";
            inline_leave_cause.Read_Only = false;
            inline_leave_cause.BorderStyle = BorderStyle.None;
            foreach (Istab i in this.leave_cause)
            {
                ComboboxItem item = new ComboboxItem(i.typdes_th, i.id, i.typcod);
                item.Tag = i;
                inline_leave_cause.AddItem(item);
                if (this.form_mode == FORM_MODE.EDIT_ITEM)
                {
                    if (i.tabtyp == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).event_type && i.typcod == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).event_code)
                    {
                        inline_leave_cause.comboBox1.SelectedItem = item;
                    }
                }
            }
            inline_leave_cause.comboBox1.SelectedIndex = (this.form_mode == FORM_MODE.EDIT_ITEM ? this.leave_cause.FindIndex(t => t.typcod == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).event_code) : 0);
            this.dgv.Parent.Controls.Add(inline_leave_cause);

            CustomTimePicker inline_from_time = new CustomTimePicker();
            inline_from_time.Name = "inline_from_time";
            inline_from_time.Read_Only = false;
            inline_from_time.BorderStyle = BorderStyle.None;
            inline_from_time.Show_Second = false;
            this.dgv.Parent.Controls.Add(inline_from_time);
            inline_from_time.Time = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).from_time.TimeString2DateTime() : new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 30, 0));

            CustomTimePicker inline_to_time = new CustomTimePicker();
            inline_to_time.Name = "inline_to_time";
            inline_to_time.Read_Only = false;
            inline_to_time.BorderStyle = BorderStyle.None;
            inline_to_time.Show_Second = false;
            this.dgv.Parent.Controls.Add(inline_to_time);
            inline_to_time.Time = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).to_time.TimeString2DateTime() : (this.cde.date.Value.GetDayIntOfWeek() == 7 ? new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 12, 00, 0) : new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 30, 0)));

            CustomComboBox inline_status = new CustomComboBox();
            inline_status.Name = "inline_status";
            inline_status.Read_Only = false;
            inline_status.BorderStyle = BorderStyle.None;
            inline_status.AddItem(new ComboboxItem("Wait", 0, "Wait"));
            inline_status.AddItem(new ComboboxItem("Confirmed", 1, "Confirmed"));
            inline_status.AddItem(new ComboboxItem("Canceled", 2, "Canceled"));
            this.dgv.Parent.Controls.Add(inline_status);
            inline_status.comboBox1.SelectedIndex = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).status : 1);

            CustomTextBox inline_customer = new CustomTextBox();
            inline_customer.Name = "inline_customer";
            inline_customer.Read_Only = false;
            inline_customer.MaxChar = 40;
            inline_customer.BorderStyle = BorderStyle.None;
            this.dgv.Parent.Controls.Add(inline_customer);
            inline_customer.Texts = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).customer : "");

            CustomComboBox inline_medcert = new CustomComboBox();
            inline_medcert.Name = "inline_medcert";
            inline_medcert.Read_Only = false;
            inline_medcert.BorderStyle = BorderStyle.None;
            inline_medcert.AddItem(new ComboboxItem("N/A (ไม่ระบุ)", 9, "X"));
            inline_medcert.AddItem(new ComboboxItem("ไม่มีเอกสาร", 0, "N"));
            inline_medcert.AddItem(new ComboboxItem("มีใบรับรองแพทย์", 1, "Y"));
            this.dgv.Parent.Controls.Add(inline_medcert);
            inline_medcert.comboBox1.SelectedItem = (this.form_mode == FORM_MODE.EDIT_ITEM ? inline_medcert.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.string_value == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).med_cert).First<ComboboxItem>() : (ComboboxItem)inline_medcert.comboBox1.Items[0]);

            NumericUpDown inline_fine = new NumericUpDown();
            inline_fine.Name = "inline_fine";
            inline_fine.Maximum = 1000;
            inline_fine.Minimum = 0;
            inline_fine.AutoSize = false;
            inline_fine.Font = new Font("tahoma", 9.75f);
            inline_fine.ThousandsSeparator = true;
            inline_fine.BorderStyle = BorderStyle.None;
            inline_fine.TextAlign = HorizontalAlignment.Right;
            this.dgv.Parent.Controls.Add(inline_fine);
            inline_fine.Value = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).fine : 0);

            this.SetInlineFormPosition();
            this.dgv.SendToBack();
            this.dgv.Enabled = false;
            inline_users_name.BringToFront();
            inline_leave_cause.BringToFront();
            inline_from_time.BringToFront();
            inline_to_time.BringToFront();
            inline_status.BringToFront();
            inline_customer.BringToFront();
            inline_medcert.BringToFront();
            inline_fine.BringToFront();
        }
Esempio n. 6
0
        private void ShowInlineFormLeaveList()
        {
            this.FormEditItem();
            CustomTimePicker inline_from_time = new CustomTimePicker();
            inline_from_time.Name = "inline_from_time";
            inline_from_time.Read_Only = false;
            this.dgvLeaveList.Parent.Controls.Add(inline_from_time);

            CustomTimePicker inline_to_time = new CustomTimePicker();
            inline_to_time.Name = "inline_to_time";
            inline_to_time.Read_Only = false;
            this.dgvLeaveList.Parent.Controls.Add(inline_to_time);

            CustomComboBox inline_status = new CustomComboBox();
            inline_status.Name = "inline_status";
            inline_status.Read_Only = false;
            inline_status.BorderStyle = BorderStyle.None;
            inline_status.AddItem(new ComboboxItem("WAIT", (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM, "WAIT"));
            inline_status.AddItem(new ComboboxItem("CONFIRMED", (int)CustomDateEvent.EVENT_STATUS.CONFIRMED, "CONFIRMED"));
            inline_status.AddItem(new ComboboxItem("CANCELED", (int)CustomDateEvent.EVENT_STATUS.CANCELED, "CANCELED"));
            this.dgvLeaveList.Parent.Controls.Add(inline_status);

            CustomTextBox inline_customer = new CustomTextBox();
            inline_customer.Name = "inline_customer";
            inline_customer.Read_Only = false;
            inline_customer.BorderStyle = BorderStyle.None;
            inline_customer.MaxChar = 40;
            this.dgvLeaveList.Parent.Controls.Add(inline_customer);

            CustomComboBox inline_medcert = new CustomComboBox();
            inline_medcert.Name = "inline_medcert";
            inline_medcert.Read_Only = false;
            inline_medcert.BorderStyle = BorderStyle.None;
            inline_medcert.AddItem(new ComboboxItem("N/A (ไม่ระบุ)", 9, "X"));
            inline_medcert.AddItem(new ComboboxItem("ไม่มีใบรับรองแพทย์", 0, "N"));
            inline_medcert.AddItem(new ComboboxItem("มีใบรับรองแพทย์", 1, "Y"));
            this.dgvLeaveList.Parent.Controls.Add(inline_medcert);

            NumericUpDown inline_fine = new NumericUpDown();
            inline_fine.Name = "inline_fine";
            inline_fine.Font = new Font("tahoma", 9.75f);
            inline_fine.Maximum = 1000;
            inline_fine.Minimum = 0;
            inline_fine.BorderStyle = BorderStyle.None;
            inline_fine.TextAlign = HorizontalAlignment.Right;
            inline_fine.GotFocus += delegate
            {
                inline_fine.Select(0, inline_fine.Text.Length);
            };
            this.dgvLeaveList.Parent.Controls.Add(inline_fine);

            this.SetPositionFormLeaveList();
            this.dgvAbsentSummary.Enabled = false;
            this.dgvLeaveList.Enabled = false;
            this.dgvLeaveList.SendToBack();
            inline_from_time.BringToFront();
            inline_to_time.BringToFront();
            inline_status.BringToFront();
            inline_customer.BringToFront();
            inline_medcert.BringToFront();
            inline_fine.BringToFront();

            if (this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag is EventCalendar)
            {
                string[] from = ((EventCalendar)this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag).from_time.Split(':');
                inline_from_time.Time = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(from[0]), Convert.ToInt32(from[1]), 0);
                string[] to = ((EventCalendar)this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag).to_time.Split(':');
                inline_to_time.Time = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(to[0]), Convert.ToInt32(to[1]), 0);
                inline_status.comboBox1.SelectedItem = inline_status.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.int_value == ((EventCalendar)this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag).status).First<ComboboxItem>();
                inline_customer.Texts = ((EventCalendar)this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag).customer;
                inline_medcert.comboBox1.SelectedItem = inline_medcert.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.string_value == ((EventCalendar)this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag).med_cert).First<ComboboxItem>();
                inline_fine.Value = ((EventCalendar)this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag).fine;
            }
        }