Example #1
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 #2
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;
            }
        }