Example #1
0
        private void ClearInlineForm(DataGridView dgv)
        {
            this.prepared_comment = null;
            if (this.inline_comment_desc != null)
            {
                this.inline_comment_desc.Dispose();
                this.inline_comment_desc = null;
            }
            dgv.Enabled = true;

            if (dgv.Rows.Cast<DataGridViewRow>().Where(r => !(r.Tag is SupportNoteComment)).Count<DataGridViewRow>() > 0)
                dgv.Rows.Remove(dgv.Rows.Cast<DataGridViewRow>().Where(r => !(r.Tag is SupportNoteComment)).First<DataGridViewRow>());
        }
Example #2
0
        private void ShowInlineForm(COMMENT_TYPE comment_type, FORM_MODE mode)
        {
            this.curr_comment_type = comment_type;

            DataGridView dgv = null;
            switch (comment_type)
            {
                case COMMENT_TYPE.COMMENT:
                    dgv = this.dgvComment;
                    this.inline_comment_desc = new CustomTextBox()
                    {
                        Read_Only = false
                    };
                    dgv.Parent.Controls.Add(this.inline_comment_desc);
                    break;
                case COMMENT_TYPE.COMPLAIN:
                    dgv = this.dgvComplain;
                    this.inline_comment_desc = new CustomTextBox()
                    {
                        Read_Only = false
                    };
                    dgv.Parent.Controls.Add(this.inline_comment_desc);
                    break;
                case COMMENT_TYPE.NONE:
                    break;
                default:
                    break;
            }

            if (dgv != null && mode == FORM_MODE.ADD)
            {
                dgv.Rows[dgv.Rows.Add()].Cells[0].Selected = true;
                this.prepared_comment = new SupportNoteComment();
                this.prepared_comment.id = -1;
                this.prepared_comment.type = (int)comment_type;
                this.prepared_comment.note_id = this.note_id;
                this.prepared_comment.rec_by = this.parent_wind.main_form.G.loged_in_user_name;
                this.FormAdd();
            }

            if (dgv != null && mode == FORM_MODE.EDIT && dgv.Rows[dgv.CurrentCell.RowIndex].Tag is SupportNoteComment)
            {
                this.prepared_comment = (SupportNoteComment)dgv.Rows[dgv.CurrentCell.RowIndex].Tag;
                this.prepared_comment.rec_by = this.parent_wind.main_form.G.loged_in_user_name;

                this.inline_comment_desc.Texts = this.prepared_comment.description;
                this.FormEdit();
            }

            this.SetInlineFormPosition(dgv);
            dgv.Enabled = false;
            dgv.SendToBack();
            this.inline_comment_desc.BringToFront();
            this.inline_comment_desc.Focus();
            this.inline_comment_desc.SelectionStart = 0;
            this.inline_comment_desc.SelectionLength = 0;

            dgv.Tag = HelperClass.DGV_TAG.READ;
            dgv.Refresh();
        }
Example #3
0
        private void AddFormMsg()
        {
            this.FormAddItemF8();
            this.dgvMsg.Rows[this.d_msg.Count].Cells[1].Selected = true;

            CustomDateTimePicker inline_date = new CustomDateTimePicker();
            inline_date.Name = "inline_date";
            inline_date.BorderStyle = BorderStyle.None;
            inline_date.Read_Only = false;
            inline_date.textBox1.GotFocus += delegate
            {
                this.current_focused_control = inline_date;
            };
            CustomTextBox inline_name = new CustomTextBox();
            inline_name.Name = "inline_name";
            inline_name.BorderStyle = BorderStyle.None;
            inline_name.Read_Only = false;
            inline_name.MaxChar = 3;
            inline_name.textBox1.GotFocus += delegate
            {
                this.current_focused_control = inline_name;
            };
            CustomTextBox inline_desc = new CustomTextBox();
            inline_desc.Name = "inline_desc";
            inline_desc.BorderStyle = BorderStyle.None;
            inline_desc.Read_Only = false;
            inline_desc.MaxChar = 100;
            inline_desc.textBox1.GotFocus += delegate
            {
                this.current_focused_control = inline_desc;
            };
            inline_desc.textBox1.KeyDown += delegate(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    this.toolStripSave.PerformClick();
                }
            };

            this.dgvMsg.Parent.Controls.Add(inline_date);
            this.dgvMsg.Parent.Controls.Add(inline_name);
            this.dgvMsg.Parent.Controls.Add(inline_desc);

            this.AdjustInlineForm();

            this.dgvMsg.Enabled = false;
            this.dgvMsg.SendToBack();
            inline_date.BringToFront();
            inline_date.dateTimePicker1.Value = DateTime.Now;
            inline_name.BringToFront();
            inline_desc.BringToFront();

            inline_date.Focus();
        }
Example #4
0
        private void EditFormMsg(int column_index)
        {
            if (this.dgvMsg.Rows[this.dgvMsg.CurrentCell.RowIndex].Tag is D_msg)
            {
                this.FormEditItemF8();
                int row_index = this.dgvMsg.CurrentCell.RowIndex;

                CustomDateTimePicker inline_date = new CustomDateTimePicker();
                inline_date.Name = "inline_date";
                inline_date.BorderStyle = BorderStyle.None;
                inline_date.Read_Only = false;
                inline_date.textBox1.GotFocus += delegate
                {
                    this.current_focused_control = inline_date;
                };
                CustomTextBox inline_name = new CustomTextBox();
                inline_name.Name = "inline_name";
                inline_name.BorderStyle = BorderStyle.None;
                inline_name.Read_Only = false;
                inline_name.MaxChar = 3;
                inline_name.textBox1.GotFocus += delegate
                {
                    this.current_focused_control = inline_name;
                };
                CustomTextBox inline_desc = new CustomTextBox();
                inline_desc.Name = "inline_desc";
                inline_desc.BorderStyle = BorderStyle.None;
                inline_desc.Read_Only = false;
                inline_desc.MaxChar = 100;
                inline_desc.textBox1.GotFocus += delegate
                {
                    this.current_focused_control = inline_desc;
                };
                inline_desc.textBox1.KeyDown += delegate(object sender, KeyEventArgs e)
                {
                    if (e.KeyCode == Keys.Enter)
                    {
                        this.toolStripSave.PerformClick();
                    }
                };

                this.dgvMsg.Parent.Controls.Add(inline_date);
                this.dgvMsg.Parent.Controls.Add(inline_name);
                this.dgvMsg.Parent.Controls.Add(inline_desc);
                inline_date.TextsMysql = ((D_msg)this.dgvMsg.Rows[row_index].Tag).date;
                inline_name.Texts = ((D_msg)this.dgvMsg.Rows[row_index].Tag).name;
                inline_desc.Texts = ((D_msg)this.dgvMsg.Rows[row_index].Tag).description;

                this.AdjustInlineForm();

                this.dgvMsg.Enabled = false;
                this.dgvMsg.SendToBack();
                inline_date.BringToFront();
                inline_name.BringToFront();
                inline_desc.BringToFront();

                if (this.dgvMsg.Rows[row_index].Cells[column_index] != null)
                {
                    if (column_index == 1)
                    {
                        inline_date.Focus();
                    }
                    else if (column_index == 2)
                    {
                        inline_name.Focus();
                    }
                    else if (column_index == 3)
                    {
                        inline_desc.Focus();
                    }
                }
                else
                {
                    inline_date.Focus();
                }
            }
        }
Example #5
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();
        }
Example #6
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;
     }
 }
Example #7
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();
        }
Example #8
0
        private void showInlineProblemForm(DataGridViewRow row, int column_index = 1, Problem pattern = null)
        {
            this.dgvProblem.Enabled = false;

            Problem prob = new Problem();

            CustomDateTimePicker date = new CustomDateTimePicker();
            date.Name = "inline_problem_date";
            date.BringToFront();
            date.Read_Only = false;
            date.BorderStyle = BorderStyle.None;
            date.textBox1.GotFocus += delegate
            {
                this.current_focused_control = date;
                this.toolStripInfo.Text = this.toolTip1.GetToolTip(date);
            };
            toolTip1.SetToolTip(date, "<F6> = Show Calendar");
            CustomTextBox name = new CustomTextBox();
            name.Name = "inline_problem_name";
            name.BringToFront();
            name.Read_Only = false;
            name.BorderStyle = BorderStyle.None;
            name.textBox1.GotFocus += delegate
            {
                this.current_focused_control = name;
                this.toolStripInfo.Text = this.toolTip1.GetToolTip(name);
            };
            CustomBrowseField probcod = new CustomBrowseField();
            probcod.Name = "inline_problem_probcod";
            probcod.BringToFront();
            probcod._ReadOnly = false;
            probcod._MaxLength = 2;
            probcod.BorderStyle = BorderStyle.None;
            toolTip1.SetToolTip(probcod, "<F6> = Show Problem Code");
            probcod._btnBrowse.Click += delegate
            {
                IstabList co = new IstabList(this.main_form, probcod._Text, Istab.TABTYP.PROBLEM_CODE);
                if (co.ShowDialog() == DialogResult.OK)
                {
                    probcod._Text = co.istab.typcod;
                }
            };
            CustomTextBoxMaskedWithLabel probdesc = new CustomTextBoxMaskedWithLabel();
            probdesc.Name = "inline_problem_probdesc";
            probdesc.BringToFront();
            probdesc.BorderStyle = BorderStyle.None;
            probdesc.txtEdit.Enter += delegate
            {

            };
            probdesc.txtEdit.GotFocus += delegate
            {
                if (this.main_form.data_resource.LIST_PROBLEM_CODE.Find(t => t.typcod == probcod._Text) == null)
                {
                    SendKeys.Send("+{TAB}");
                    SendKeys.Send("{F6}");
                    return;
                }
                this.current_focused_control = probdesc;
                this.toolStripInfo.Text = this.toolTip1.GetToolTip(probdesc);
            };

            if (row.Tag is Problem) // edit existing problem
            {
                this.FormEditItem();
                prob = (Problem)row.Tag;
            }
            else // add new problem
            {
                this.FormAddItem();
                if (pattern != null)
                    prob = (pattern.probcod == "RG" && this.G.loged_in_user_level < GlobalVar.USER_LEVEL_ADMIN ? prob : pattern);
            }

            this.dgvProblem.Parent.Controls.Add(date);
            this.dgvProblem.Parent.Controls.Add(name);
            this.dgvProblem.Parent.Controls.Add(probcod);
            this.dgvProblem.Parent.Controls.Add(probdesc);
            this.dgvProblem.SendToBack();

            this.setPositionInlineProblemForm(row);

            // specify value in each field
            date.TextsMysql = (row.Tag is Problem ? prob.date : DateTime.Now.ToMysqlDate());
            name.Texts = prob.name;
            probcod._Text = prob.probcod;
            if (prob.probcod == "RG" && this.main_form.G.loged_in_user_level < GlobalVar.USER_LEVEL_ADMIN)
            {
                probcod.Visible = false;
                probdesc.StaticText = this.GetMachineCode(prob.probdesc);
                probdesc.EditableText = prob.probdesc.Substring(probdesc.StaticText.Length, prob.probdesc.Length - (probdesc.StaticText.Length)).Trim();
            }
            else
            {
                probdesc.StaticText = "";
                probdesc.EditableText = prob.probdesc;
            }

            if (column_index == 1)
            {
                date.Focus();
            }
            else if (column_index == 2)
            {
                name.Focus();
            }
            else if (column_index == 3)
            {
                if (probcod.Visible)
                    probcod.Focus();

                if (!probcod.Visible)
                    probdesc.Focus();
            }
            else if (column_index == 4)
            {
                probdesc.Focus();
            }
        }
Example #9
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;
            }
        }
Example #10
0
        private void ShowInlineForm(int col_index = 1)
        {
            if (this.dgvIstab.CurrentCell == null)
                return;

            int focused_field = 1;

            if (this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag is Istab) // edit mode
            {
                this.FormEdit();
                focused_field = (col_index == 1 ? 2 : col_index);
            }
            else // add mode
            {
                this.dgvIstab.Rows[this.istabs.Count].Cells[1].Selected = true;
                this.FormAdd();
            }

            this.inline_typcod = new CustomTextBox();
            this.inline_typcod.Name = "inline_typcod";
            this.inline_typcod.Read_Only = (this.form_mode == FORM_MODE.EDIT ? true : false);
            this.inline_typcod.MaxChar = this.GetTypcodMaxChar();
            this.inline_typcod.BorderStyle = BorderStyle.None;
            this.inline_typcod.Texts = (this.form_mode == FORM_MODE.EDIT ? ((Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag).typcod : "");
            this.inline_typcod.textBox1.GotFocus += delegate
            {
                this.inline_typcod.SelectionStart = this.inline_typcod.Texts.Length;
                this.current_focused_control = this.inline_typcod.textBox1;
            };
            this.dgvIstab.Parent.Controls.Add(this.inline_typcod);

            this.inline_abbr_th = new CustomTextBox();
            this.inline_abbr_th.Name = "inline_abbr_th";
            this.inline_abbr_th.Read_Only = false;
            this.inline_abbr_th.MaxChar = 20;
            this.inline_abbr_th.BorderStyle = BorderStyle.None;
            this.inline_abbr_th.Texts = (this.form_mode == FORM_MODE.EDIT ? ((Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag).abbreviate_th : "");
            this.inline_abbr_th.textBox1.GotFocus += delegate
            {
                this.inline_abbr_th.SelectionStart = this.inline_abbr_th.Texts.Length;
                this.current_focused_control = this.inline_abbr_th.textBox1;

                if (this.inline_typcod.Texts.Length == 0)
                {
                    this.inline_typcod.Focus();
                }
            };
            this.dgvIstab.Parent.Controls.Add(this.inline_abbr_th);

            this.inline_abbr_en = new CustomTextBox();
            this.inline_abbr_en.Name = "inline_abbr_en";
            this.inline_abbr_en.Read_Only = false;
            this.inline_abbr_en.MaxChar = 20;
            this.inline_abbr_en.BorderStyle = BorderStyle.None;
            this.inline_abbr_en.Texts = (this.form_mode == FORM_MODE.EDIT ? ((Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag).abbreviate_en : "");
            this.inline_abbr_en.textBox1.GotFocus += delegate
            {
                this.inline_abbr_en.SelectionStart = this.inline_abbr_en.Texts.Length;
                this.current_focused_control = this.inline_abbr_en.textBox1;

                if (this.inline_typcod.Texts.Length == 0)
                {
                    this.inline_typcod.Focus();
                }
            };
            this.dgvIstab.Parent.Controls.Add(this.inline_abbr_en);

            this.inline_typdes_th = new CustomTextBox();
            this.inline_typdes_th.Name = "inline_typdes_th";
            this.inline_typdes_th.Read_Only = false;
            this.inline_typdes_th.MaxChar = 50;
            this.inline_typdes_th.BorderStyle = BorderStyle.None;
            this.inline_typdes_th.Texts = (this.form_mode == FORM_MODE.EDIT ? ((Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag).typdes_th : "");
            this.inline_typdes_th.textBox1.GotFocus += delegate
            {
                this.inline_typdes_th.SelectionStart = this.inline_typdes_th.Texts.Length;
                this.current_focused_control = this.inline_typdes_th.textBox1;

                if (this.inline_typcod.Texts.Length == 0)
                {
                    this.inline_typcod.Focus();
                }
            };
            this.dgvIstab.Parent.Controls.Add(this.inline_typdes_th);

            this.inline_typdes_en = new CustomTextBox();
            this.inline_typdes_en.Name = "inline_typdes_en";
            this.inline_typdes_en.Read_Only = false;
            this.inline_typdes_en.MaxChar = 50;
            this.inline_typdes_en.BorderStyle = BorderStyle.None;
            this.inline_typdes_en.Texts = (this.form_mode == FORM_MODE.EDIT ? ((Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag).typdes_en : "");
            this.inline_typdes_en.textBox1.GotFocus += delegate
            {
                this.inline_typdes_en.SelectionStart = this.inline_typdes_en.Texts.Length;
                this.current_focused_control = this.inline_typdes_en.textBox1;

                if (this.inline_typcod.Texts.Length == 0)
                {
                    this.inline_typcod.Focus();
                }
            };
            this.dgvIstab.Parent.Controls.Add(this.inline_typdes_en);

            this.SetInlineFormPosition();

            this.inline_typcod.BringToFront();
            this.inline_abbr_th.BringToFront();
            this.inline_abbr_en.BringToFront();
            this.inline_typdes_th.BringToFront();
            this.inline_typdes_en.BringToFront();
            this.dgvIstab.SendToBack();

            if (focused_field == 1)
            {
                this.inline_typcod.textBox1.Focus();
                return;
            }
            if (focused_field == 2)
            {
                this.inline_abbr_th.textBox1.Focus();
                return;
            }
            if (focused_field == 3)
            {
                this.inline_abbr_en.textBox1.Focus();
                return;
            }
            if (focused_field == 4)
            {
                this.inline_typdes_th.textBox1.Focus();
                return;
            }
            if (focused_field == 5)
            {
                this.inline_typdes_en.textBox1.Focus();
                return;
            }
        }
Example #11
0
        private void ClearInlineForm()
        {
            if (this.inline_typcod != null)
            {
                this.inline_typcod.Dispose();
                this.inline_typcod = null;
            }
            if (this.inline_abbr_th != null)
            {
                this.inline_abbr_th.Dispose();
                this.inline_abbr_th = null;
            }
            if (this.inline_abbr_en != null)
            {
                this.inline_abbr_en.Dispose();
                this.inline_abbr_en = null;
            }
            if (this.inline_typdes_th != null)
            {
                this.inline_typdes_th.Dispose();
                this.inline_typdes_th = null;
            }
            if (this.inline_typdes_en != null)
            {
                this.inline_typdes_en.Dispose();
                this.inline_typdes_en = null;
            }

            this.current_focused_control = null;
        }