Exemple #1
0
 public IstabWindow(MainForm main_form, Istab.TABTYP tabtyp)
 {
     InitializeComponent();
     this.main_form = main_form;
     this.tabtyp = tabtyp;
     this.sort = SORT_BY.TYPCOD;
 }
Exemple #2
0
 //public IstabList(SnWindow parent_window, string typcod, Istab.TABTYP tabtyp)
 public IstabList(MainForm main_form, string typcod, Istab.TABTYP tabtyp)
     : this()
 {
     //this.parent_window = parent_window;
     this.main_form = main_form;
     this.tabtyp = tabtyp;
     this.selected_typcod = typcod;
     this.setTitleText();
     this.sort_by = SORT_TYPCOD;
 }
Exemple #3
0
        /// <summary>
        /// Form for Add/Edit istab data
        /// </summary>
        /// <param name="mode">Specify mode (add or edit)</param>
        /// <param name="tabtyp">Tabtyp value</param>
        /// <param name="istab_data">istab data to edit(for edit mode only)</param>
        public IstabAddEditForm(FORM_MODE mode, Istab.TABTYP tabtyp, Istab istab_data = null)
        {
            InitializeComponent();
            this.istab = istab_data;
            this.tabtyp = tabtyp;

            EscapeKeyToCloseDialog.ActiveEscToClose(this);
            EnterKeyManager.Active(this);

            this.mode = mode;

            this.initializeForm();
        }
Exemple #4
0
 private List<Istab> getIstabDataFromServer(Istab.TABTYP tabtyp)
 {
     CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "istab/get_all&tabtyp=" + tabtyp.ToTabtypString() + "&sort=typcod");
     ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(get.data);
     if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
     {
         if (sr.istab.Count > 0)
         {
             return sr.istab;
         }
         else
         {
             return new List<Istab>();
         }
     }
     else
     {
         return new List<Istab>();
     }
 }
Exemple #5
0
 public static string getTabtypString(Istab.TABTYP tabtyp)
 {
     switch (tabtyp)
     {
         case Istab.TABTYP.AREA:
             return "01";
         case Istab.TABTYP.VEREXT:
             return "02";
         case Istab.TABTYP.HOWKNOWN:
             return "03";
         case Istab.TABTYP.BUSITYP:
             return "04";
         case Istab.TABTYP.PROBLEM_CODE:
             return "05";
         case Istab.TABTYP.ABSENT_CAUSE:
             return "06";
         case Istab.TABTYP.SERVICE_CASE:
             return "07";
         case Istab.TABTYP.USER_GROUP:
             return "08";
         default:
             return "00";
     }
 }
Exemple #6
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageAlert.Show("ลบกลุ่มผู้ใช้นี้ , สมาชิกในกลุ่มจะถูกนำออกจากกลุ่มด้วย\nดำเนินการต่อ?", "", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.QUESTION) == DialogResult.OK)
            {
                bool delete_success = false;
                string err_msg = "";
                int deleted_list_index = this.list_group.FindIndex(g => g.id == this.current_group.id);

                this.FormProcessing();
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += delegate
                {
                    CRUDResult delete = ApiActions.DELETE(PreferenceForm.API_MAIN_URL() + "istab/delete_users_group&id=" + this.current_group.id.ToString());
                    ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(delete.data);

                    if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                    {
                        delete_success = true;
                    }
                    else
                    {
                        delete_success = false;
                        err_msg = sr.message;
                    }
                };
                worker.RunWorkerCompleted += delegate
                {
                    if (delete_success)
                    {
                        this.LoadDependenciesData();
                        this.current_group = (this.list_group.Count == 0 ? null : (deleted_list_index < this.list_group.Count - 1 ? this.list_group[deleted_list_index] : this.list_group.First<Istab>()));
                        this.FillForm(this.current_group);
                        this.FormRead();
                    }
                    else
                    {
                        this.FormRead();
                        MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                    }
                };
                worker.RunWorkerAsync();
            }
        }
Exemple #7
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     this.FormAddGroup();
     this.processing_group = new Istab()
     {
         id = -1
     };
     this.FillForm(this.processing_group);
     this.txtTypcod.textBox1.Focus();
 }
Exemple #8
0
        private void UsersGroupWindow_Shown(object sender, EventArgs e)
        {
            if (this.list_group.Count > 0)
            {
                this.current_group = this.list_group.First<Istab>();
                this.FillForm(this.current_group);
            }

            this.FillDgvMember(this.current_group);
            this.FillDgvUngroup();
            this.FormRead();
        }
Exemple #9
0
 private void RefreshCurrentData()
 {
     this.LoadDependenciesData();
     if (this.list_group.Count > 0)
     {
         this.current_group = (this.list_group.Find(g => g.id == this.current_group.id) != null ? this.list_group.Find(g => g.id == this.current_group.id) : this.list_group.First<Istab>());
     }
     else
     {
         this.current_group = null;
     }
 }
Exemple #10
0
 public static string getTabtypTitle(Istab.TABTYP tabtyp)
 {
     switch (tabtyp)
     {
         case TABTYP.AREA:
             return "Sales Area";
         case TABTYP.VEREXT:
             return "Version Extension";
         case TABTYP.HOWKNOWN:
             return "How to Know";
         case TABTYP.BUSITYP:
             return "Business Type";
         case TABTYP.PROBLEM_CODE:
             return "Problem Code";
         case TABTYP.ABSENT_CAUSE:
             return "Absent Cause";
         case TABTYP.SERVICE_CASE:
             return "Service Case";
         case TABTYP.USER_GROUP:
             return "User Group";
         default:
             return "Istab";
     }
 }
Exemple #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            #region Add/Edit Group
            if (this.form_mode == FORM_MODE.ADD_GROUP || this.form_mode == FORM_MODE.EDIT_GROUP)
            {
                string json_data = "{\"id\":" + this.processing_group.id.ToString() + ",";
                json_data += "\"tabtyp\":\"" + Istab.TABTYP.USER_GROUP.ToTabtypString() + "\",";
                json_data += "\"typcod\":\"" + this.txtTypcod.Texts.cleanString() + "\",";
                json_data += "\"abbreviate_th\":\"\",";
                json_data += "\"abbreviate_en\":\"\",";
                json_data += "\"typdes_th\":\"" + this.txtTypdes.Texts.cleanString() + "\",";
                json_data += "\"typdes_en\":\"\"}";

                //Console.WriteLine(" >> " + json_data);
                bool post_success = false;
                string err_msg = "";
                Istab inserted_group = null;

                if (this.form_mode == FORM_MODE.ADD_GROUP)
                {
                    this.FormProcessing();

                    BackgroundWorker worker = new BackgroundWorker();
                    worker.DoWork += delegate
                    {
                        CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "istab/create", json_data);
                        ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(post.data);
                        if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                        {
                            post_success = true;
                            inserted_group = sr.istab[0];
                        }
                        else
                        {
                            post_success = false;
                            err_msg = sr.message;
                        }
                    };
                    worker.RunWorkerCompleted += delegate
                    {
                        if (post_success)
                        {
                            this.LoadDependenciesData();
                            this.current_group = inserted_group;
                            this.FillForm(this.current_group);
                            this.FormRead();
                        }
                        else
                        {
                            MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                            this.FormAddGroup();
                            this.txtTypdes.textBox1.Focus();
                        }
                    };
                    worker.RunWorkerAsync();
                }

                if (this.form_mode == FORM_MODE.EDIT_GROUP)
                {
                    this.FormProcessing();

                    BackgroundWorker worker = new BackgroundWorker();
                    worker.DoWork += delegate
                    {
                        Console.WriteLine(" >> " + json_data);
                        CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "istab/submit_change", json_data);
                        ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(post.data);
                        if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                        {
                            post_success = true;
                            inserted_group = sr.istab[0];
                        }
                        else
                        {
                            post_success = false;
                            err_msg = sr.message;
                        }
                    };
                    worker.RunWorkerCompleted += delegate
                    {
                        if (post_success)
                        {
                            this.LoadDependenciesData();
                            this.current_group = inserted_group;
                            this.FillForm(this.current_group);
                            this.FormRead();
                        }
                        else
                        {
                            MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                            this.FormAddGroup();
                            this.txtTypdes.textBox1.Focus();
                        }
                    };
                    worker.RunWorkerAsync();
                }
            }

            #endregion Add/Edit Group

            #region Add Member
            if (this.form_mode == FORM_MODE.ADD_F8)
            {
                if (this.inline_user.comboBox1.SelectedItem == null)
                {
                    MessageAlert.Show("กรุณาเลือกรหัสพนักงาน", "", MessageAlertButtons.OK, MessageAlertIcons.NONE);
                    return;
                }

                string json_data = "{\"id\":" + ((Users)((ComboboxItem)this.inline_user.comboBox1.SelectedItem).Tag).id.ToString() + ",";
                json_data += "\"usergroup\":\"" + this.current_group.typcod + "\",";
                json_data += "\"rec_by\":\"" + this.main_form.G.loged_in_user_name + "\"}";

                bool post_success = false;
                string err_msg = "";
                Users edited_user = null;

                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += delegate
                {
                    CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "users/change_group", json_data);
                    ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(post.data);
                    if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                    {
                        post_success = true;
                        edited_user = sr.users[0];
                    }
                    else
                    {
                        post_success = false;
                        err_msg = sr.message;
                    }
                };
                worker.RunWorkerCompleted += delegate
                {
                    if (post_success)
                    {
                        this.RefreshCurrentData();
                        this.FillForm(this.current_group);
                        this.FormReadF8();
                        this.ShowInlineForm(FORM_MODE.ADD_F8);
                        this.FormAddF8();
                        return;
                    }

                    MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                    this.FormAddF8();
                };
                worker.RunWorkerAsync();
            }
            #endregion Add Member
        }
Exemple #12
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            this.LoadDependenciesData();
            if (this.list_group.Find(g => g.id == this.current_group.id) != null)
            {
                int curr_index = this.list_group.FindIndex(g => g.id == this.current_group.id);
                this.current_group = (curr_index < this.list_group.Count - 1 ? this.list_group[curr_index + 1] : this.list_group.Last<Istab>());
            }
            else
            {
                this.current_group = this.list_group.Last<Istab>();
            }

            this.FillForm(this.current_group);
        }
Exemple #13
0
        private void showEditForm(Istab istab)
        {
            IstabAddEditForm wind = new IstabAddEditForm(IstabAddEditForm.FORM_MODE.EDIT, this.tabtyp, istab);

            if (wind.ShowDialog() == DialogResult.OK)
            {
                this.main_form.data_resource.Refresh();
                this.fillInDataGrid(this.WhichDataToUse());
                this.setSelectedItem(wind.istab);
                this.dgvIstab.Focus();
            }
            else
            {
                this.dgvIstab.Focus();
            }
        }
Exemple #14
0
 private void showConfirmDelete(Istab istab)
 {
     if (MessageAlert.Show(StringResource.CONFIRM_DELETE, "", MessageAlertButtons.YES_NO, MessageAlertIcons.QUESTION) == DialogResult.Yes)
     {
         CRUDResult delete = ApiActions.DELETE(PreferenceForm.API_MAIN_URL() + "istab/delete&id=" + istab.id);
         ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(delete.data);
         if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
         {
             this.main_form.data_resource.Refresh();
             this.fillInDataGrid(this.WhichDataToUse());
             this.dgvIstab.Focus();
         }
         else
         {
             MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
             this.dgvIstab.Focus();
         }
     }
     else
     {
         this.dgvIstab.Focus();
     }
 }
Exemple #15
0
 private void setSelectedItem(Istab selected_item = null)
 {
     if (selected_item == null)
     {
         foreach (DataGridViewRow row in this.dgvIstab.Rows)
         {
             if (string.CompareOrdinal(this.selected_typcod, ((Istab)row.Tag).typcod) <= 0)
             {
                 row.Cells[1].Selected = true;
                 break;
             }
         }
     }
     else
     {
         foreach (DataGridViewRow row in this.dgvIstab.Rows)
         {
             if (((Istab)row.Tag).typcod == selected_item.typcod)
             {
                 row.Cells[1].Selected = true;
                 break;
             }
         }
     }
     this.dgvIstab.Focus();
 }
Exemple #16
0
        private void returnSelectedResult()
        {
            this.istab = (Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag;

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemple #17
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (this.txtTypcod.Text.Length > 0)
            {
                CRUDResult post;
                if (this.mode == FORM_MODE.ADD) // Add
                {
                    Console.WriteLine("current tabtyp = " + Istab.getTabtypString(this.tabtyp));
                    string json_data = "{\"tabtyp\":\"" + Istab.getTabtypString(this.tabtyp) + "\",";
                    json_data += "\"typcod\":\"" + this.txtTypcod.Text.cleanString() + "\",";
                    json_data += "\"abbreviate_en\":\"" + this.txtAbbreviate_en.Text.cleanString() + "\",";
                    json_data += "\"abbreviate_th\":\"" + this.txtAbbreviate_th.Text.cleanString() + "\",";
                    json_data += "\"typdes_en\":\"" + this.txtTypdes_en.Text.cleanString() + "\",";
                    json_data += "\"typdes_th\":\"" + this.txtTypdes_th.Text.cleanString() + "\"}";

                    Console.WriteLine(json_data);
                    post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "istab/create", json_data);
                }
                else // Edit
                {
                    string json_data = "{\"id\":" + this.istab.id.ToString() + ",";
                    json_data += "\"tabtyp\":\"" + this.istab.tabtyp + "\",";
                    json_data += "\"typcod\":\"" + this.istab.typcod + "\",";
                    json_data += "\"abbreviate_en\":\"" + this.txtAbbreviate_en.Text.cleanString() + "\",";
                    json_data += "\"abbreviate_th\":\"" + this.txtAbbreviate_th.Text.cleanString() + "\",";
                    json_data += "\"typdes_en\":\"" + this.txtTypdes_en.Text.cleanString() + "\",";
                    json_data += "\"typdes_th\":\"" + this.txtTypdes_th.Text.cleanString() + "\"}";

                    Console.WriteLine(json_data);
                    post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "istab/submit_change", json_data);
                }

                ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(post.data);
                Console.WriteLine(post.data);
                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    if (sr.istab != null)
                    {
                        this.istab = sr.istab[0];
                    }
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                }

            }
            else
            {
                MessageAlert.Show(StringResource.PLEASE_FILL_CODE, "Warning", MessageAlertButtons.OK, MessageAlertIcons.WARNING);
                this.txtTypcod.Focus();
            }
        }
Exemple #18
0
        private void GetIstabData(Istab selected_item = null, bool performadd = false, int selected_row_index_after_delete = -1)
        {
            this.FormProcessing();

            string sort = "";

            switch (this.sort)
            {
                case SORT_BY.TYPCOD:
                    sort = "typcod";
                    break;
                case SORT_BY.ABBR_TH:
                    sort = "abbreviate_th";
                    break;
                case SORT_BY.ABBR_EN:
                    sort = "abbreviate_en";
                    break;
                case SORT_BY.DESC_TH:
                    sort = "typdes_th";
                    break;
                case SORT_BY.DESC_EN:
                    sort = "typdes_en";
                    break;
                default:
                    sort = "typcod";
                    break;
            }
            bool get_success = false;
            string err_msg = "";

            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += delegate
            {
                CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "istab/get_all&tabtyp=" + this.tabtyp.ToTabtypString() + "&sort=" + sort);
                ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(get.data);
                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    get_success = true;
                    this.istabs = sr.istab;
                    this.main_form.data_resource.Refresh();
                }
                else
                {
                    get_success = false;
                    err_msg = sr.message;
                }
            };
            worker.RunWorkerCompleted += delegate
            {
                if (get_success)
                {
                    this.FillInDatagrid(selected_item);
                    this.FormRead();
                    if (performadd)
                    {
                        this.toolStripAdd.PerformClick();
                    }
                    if (selected_row_index_after_delete > -1)
                    {
                        this.dgvIstab.Rows[selected_row_index_after_delete].Cells[1].Selected = true;
                    }
                }
                else
                {
                    MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                    this.FormRead();
                }
            };
            worker.RunWorkerAsync();
        }
Exemple #19
0
        private void IstabAddEditForm_Load(object sender, EventArgs e)
        {
            if (this.mode == FORM_MODE.ADD)
            {
                this.Text = "Add data : " + Istab.getTabtypTitle(this.tabtyp);
                this.txtTypcod.Focus();
            }
            else
            {
                this.Text = "Edit data : " + Istab.getTabtypTitle(this.tabtyp);
                this.txtTypcod.Enabled = false;
                this.txtAbbreviate_th.Focus();

                CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "istab/get_by_id&id=" + this.istab.id);
                ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(get.data);
                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    if (sr.istab != null)
                    {
                        this.istab = sr.istab.First<Istab>();
                        this.txtTypcod.Text = this.istab.typcod;
                        this.txtAbbreviate_en.Text = this.istab.abbreviate_en;
                        this.txtAbbreviate_th.Text = this.istab.abbreviate_th;
                        this.txtTypdes_en.Text = this.istab.typdes_en;
                        this.txtTypdes_th.Text = this.istab.typdes_th;
                    }
                }
            }
        }
Exemple #20
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     this.RefreshCurrentData();
     this.FormEditGroup();
     this.processing_group = new Istab()
     {
         id = this.current_group.id,
         tabtyp = this.current_group.tabtyp,
         typcod = this.current_group.typcod,
         abbreviate_th = this.current_group.abbreviate_th,
         abbreviate_en = this.current_group.abbreviate_en,
         typdes_th = this.current_group.typdes_th,
         typdes_en = this.current_group.typdes_en
     };
     this.FillForm(this.processing_group);
     this.txtTypdes.textBox1.Focus();
 }
Exemple #21
0
 private void btnLast_Click(object sender, EventArgs e)
 {
     this.LoadDependenciesData();
     this.current_group = this.list_group.Last<Istab>();
     this.FillForm(this.current_group);
 }
Exemple #22
0
        private void FillForm(Istab group)
        {
            this.txtTypcod.Texts = (group != null ? group.typcod : "");
            this.txtTypdes.Texts = (group != null ? group.typdes_th : "");
            this.txtMemberCount.Texts = (group != null ? this.list_users.Where(u => u.usergroup == group.typcod).ToList<Users>().Count.ToString() : "");

            this.FillDgvMember(group);
            this.FillDgvUngroup();
        }
Exemple #23
0
        private void btnPrevious_Click(object sender, EventArgs e)
        {
            this.LoadDependenciesData();
            if (this.list_group.Find(g => g.id == this.current_group.id) != null)
            {
                int curr_index = this.list_group.FindIndex(g => g.id == this.current_group.id);
                this.current_group = (curr_index > 0 ? this.list_group[curr_index - 1] : this.list_group.First<Istab>());
            }
            else
            {
                this.current_group = this.list_group.First<Istab>();
            }

            this.FillForm(this.current_group);
        }
Exemple #24
0
        private Istab GetDataInForm()
        {
            Istab data = new Istab();
            if (this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag is Istab) // edit mode return row_id
            {
                data.id = ((Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag).id;
            }
            else // add mode return -1
            {
                data.id = -1;
            }

            if (this.dgvIstab.Parent.Controls.Find("inline_typcod", true).Length > 0)
            {
                data.typcod = ((CustomTextBox)this.dgvIstab.Parent.Controls.Find("inline_typcod", true)[0]).Texts;
            }
            if (this.dgvIstab.Parent.Controls.Find("inline_abbr_th", true).Length > 0)
            {
                data.abbreviate_th = ((CustomTextBox)this.dgvIstab.Parent.Controls.Find("inline_abbr_th", true)[0]).Texts;
            }
            if (this.dgvIstab.Parent.Controls.Find("inline_abbr_en", true).Length > 0)
            {
                data.abbreviate_en = ((CustomTextBox)this.dgvIstab.Parent.Controls.Find("inline_abbr_en", true)[0]).Texts;
            }
            if (this.dgvIstab.Parent.Controls.Find("inline_typdes_th", true).Length > 0)
            {
                data.typdes_th = ((CustomTextBox)this.dgvIstab.Parent.Controls.Find("inline_typdes_th", true)[0]).Texts;
            }
            if (this.dgvIstab.Parent.Controls.Find("inline_typdes_en", true).Length > 0)
            {
                data.typdes_en = ((CustomTextBox)this.dgvIstab.Parent.Controls.Find("inline_typdes_en", true)[0]).Texts;
            }

            return data;
        }
Exemple #25
0
        private void FillDgvMember(Istab group, Users selected_user = null)
        {
            this.dgvMember.Rows.Clear();
            this.dgvMember.Columns.Clear();
            this.dgvMember.Tag = HelperClass.DGV_TAG.READ;

            this.dgvMember.Columns.Add(new DataGridViewTextBoxColumn()
            {
                HeaderText = "ลำดับ",
                Width = 40
            });
            this.dgvMember.Columns.Add(new DataGridViewTextBoxColumn()
            {
                HeaderText = "รหัส",
                Width = 120
            });
            this.dgvMember.Columns.Add(new DataGridViewTextBoxColumn()
            {
                HeaderText = "ชื่อ",
                AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
            });
            this.dgvMember.Columns.Add(new DataGridViewTextBoxColumn()
            {
                HeaderText = "ระดับผู้ใช้",
                Width = 120
            });
            this.dgvMember.Columns.Add(new DataGridViewTextBoxColumn()
            {
                HeaderText = "สถานะผู้ใช้",
                Width = 120
            });

            if (group != null)
            {
                int count = 0;
                foreach (Users u in this.list_users.Where(u => u.usergroup == group.typcod).ToList<Users>())
                {
                    int r = this.dgvMember.Rows.Add();
                    this.dgvMember.Rows[r].Tag = u;

                    this.dgvMember.Rows[r].Cells[0].ValueType = typeof(int);
                    this.dgvMember.Rows[r].Cells[0].Value = ++count;
                    this.dgvMember.Rows[r].Cells[0].Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                    this.dgvMember.Rows[r].Cells[0].Style.ForeColor = Color.Gray;
                    this.dgvMember.Rows[r].Cells[0].Style.SelectionForeColor = Color.Gray;

                    this.dgvMember.Rows[r].Cells[1].ValueType = typeof(string);
                    this.dgvMember.Rows[r].Cells[1].Value = u.username;

                    this.dgvMember.Rows[r].Cells[2].ValueType = typeof(string);
                    this.dgvMember.Rows[r].Cells[2].Value = u.name;

                    this.dgvMember.Rows[r].Cells[3].ValueType = typeof(string);
                    this.dgvMember.Rows[r].Cells[3].Value = GlobalVar.GetUserLevelString(u.level);

                    this.dgvMember.Rows[r].Cells[4].ValueType = typeof(string);
                    this.dgvMember.Rows[r].Cells[4].Value = (u.status == "N" ? "ปกติ" : (u.status == "X" ? "ห้ามใช้" : ""));
                }

                this.dgvMember.FillLine(this.list_users.Where(u => u.usergroup == group.typcod).ToList<Users>().Count);
            }

            this.dgvMember.FillLine(0);
        }
Exemple #26
0
        private void GetGroupByTypcod(string typcod)
        {
            Istab target_group = null;

            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += delegate
            {
                this.LoadDependenciesData();

                if(this.list_group.Count == 0) // if list_group is null
                    return;

                if (this.list_group.Where(g => g.typcod.Length >= typcod.Length).Where(g => g.typcod.Substring(0, typcod.Length) == typcod).Count<Istab>() > 0) // if atleast 1 match
                {
                    target_group = this.list_group.Where(g => g.typcod.Length >= typcod.Length).Where(g => g.typcod.Substring(0, typcod.Length) == typcod).First<Istab>();
                    return;
                }

                if (true) // if no one match, compare with any group.typcod
                {
                    List<Istab> tmp_list = this.list_group.OrderBy(g => g.typcod, new CompareStrings()).ToList<Istab>();
                    foreach (Istab g in tmp_list)
                    {
                        if (g.typcod.CompareTo(typcod) > 0)
                        {
                            target_group = g;
                            break;
                        }
                    }

                    return;
                }
            };
            worker.RunWorkerCompleted += delegate
            {
                if (target_group != null)
                {
                    this.current_group = target_group;
                    this.FillForm(this.current_group);
                    return;
                }

                MessageAlert.Show(StringResource.DATA_NOT_FOUND, "", MessageAlertButtons.OK, MessageAlertIcons.NONE);
            };
            worker.RunWorkerAsync();
        }
Exemple #27
0
 public IstabList(MainForm main_form, string typcod, Istab.TABTYP tabtyp, List<Istab> list_istab)
     : this(main_form, typcod, tabtyp)
 {
     this.passing_list = list_istab;
 }
Exemple #28
0
        private void FillInDatagrid(Istab selected_item = null)
        {
            this.dgvIstab.Rows.Clear();
            this.dgvIstab.Columns.Clear();
            this.dgvIstab.Tag = DGV_TAG.NORMAL;
            this.dgvIstab.EnableHeadersVisualStyles = false;

            DataGridViewTextBoxColumn col0 = new DataGridViewTextBoxColumn();
            col0.HeaderText = "ID";
            col0.Width = 0;
            col0.HeaderCell.Style = new DataGridViewCellStyle()
            {
                Font = new Font("Tahoma", 9.75f, FontStyle.Bold),
                BackColor = Color.YellowGreen,
                Padding = new Padding(0, 3, 0, 3),
                Alignment = DataGridViewContentAlignment.MiddleCenter
            };
            col0.Visible = false;
            this.dgvIstab.Columns.Add(col0);

            DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn();
            col1.HeaderText = "รหัส";
            col1.Width = 80;
            col1.HeaderCell.Style = new DataGridViewCellStyle()
            {
                Font = new Font("Tahoma", 9.75f, FontStyle.Bold),
                BackColor = this.sorted_column_header,
                Padding = new Padding(0, 3, 0, 3),
                Alignment = DataGridViewContentAlignment.MiddleCenter
            };
            this.dgvIstab.Columns.Add(col1);

            DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn();
            col2.HeaderText = "ชื่อย่อไทย";
            col2.Width = 100;
            col2.HeaderCell.Style = new DataGridViewCellStyle()
            {
                Font = new Font("Tahoma", 9.75f, FontStyle.Bold),
                BackColor = this.general_column_header,
                Padding = new Padding(0, 3, 0, 3),
                Alignment = DataGridViewContentAlignment.MiddleCenter
            };
            this.dgvIstab.Columns.Add(col2);

            DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn();
            col3.HeaderText = "ชื่อย่อEng";
            col3.Width = 100;
            col3.HeaderCell.Style = new DataGridViewCellStyle()
            {
                Font = new Font("Tahoma", 9.75f, FontStyle.Bold),
                BackColor = this.general_column_header,
                Padding = new Padding(0, 3, 0, 3),
                Alignment = DataGridViewContentAlignment.MiddleCenter
            };
            this.dgvIstab.Columns.Add(col3);

            DataGridViewTextBoxColumn col4 = new DataGridViewTextBoxColumn();
            col4.HeaderText = "ชื่อเต็มไทย";
            col4.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            col4.HeaderCell.Style = new DataGridViewCellStyle()
            {
                Font = new Font("Tahoma", 9.75f, FontStyle.Bold),
                BackColor = this.general_column_header,
                Padding = new Padding(0, 3, 0, 3),
                Alignment = DataGridViewContentAlignment.MiddleCenter
            };
            this.dgvIstab.Columns.Add(col4);

            DataGridViewTextBoxColumn col5 = new DataGridViewTextBoxColumn();
            col5.HeaderText = "ชื่อเต็มEng";
            col5.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            col5.HeaderCell.Style = new DataGridViewCellStyle()
            {
                Font = new Font("Tahoma", 9.75f, FontStyle.Bold),
                BackColor = this.general_column_header,
                Padding = new Padding(0, 3, 0, 3),
                Alignment = DataGridViewContentAlignment.MiddleCenter
            };
            this.dgvIstab.Columns.Add(col5);

            foreach (Istab istab in this.istabs)
            {
                int r = this.dgvIstab.Rows.Add();
                this.dgvIstab.Rows[r].Tag = istab;
                DataGridViewRow row = this.dgvIstab.Rows[r];
                row.Height = 25;
                row.ReadOnly = true;

                row.Cells[0].ValueType = typeof(int);
                row.Cells[0].Tag = "ID";
                row.Cells[0].Value = istab.id;
                row.Cells[0].Style = new DataGridViewCellStyle()
                {
                    Font = new Font("Tahoma", 9.75f),
                    BackColor = Color.White,
                    ForeColor = Color.Black,
                    SelectionBackColor = Color.White,
                    SelectionForeColor = Color.Black,
                };

                row.Cells[1].ValueType = typeof(string);
                row.Cells[1].Value = istab.typcod;
                row.Cells[1].Style = new DataGridViewCellStyle()
                {
                    Font = new Font("Tahoma", 9.75f),
                    BackColor = Color.White,
                    ForeColor = Color.Black,
                    SelectionBackColor = Color.White,
                    SelectionForeColor = Color.Black,
                };

                row.Cells[2].ValueType = typeof(string);
                row.Cells[2].Value = istab.abbreviate_th;
                row.Cells[2].Style = new DataGridViewCellStyle()
                {
                    Font = new Font("Tahoma", 9.75f),
                    BackColor = Color.White,
                    ForeColor = Color.Black,
                    SelectionBackColor = Color.White,
                    SelectionForeColor = Color.Black,
                };

                row.Cells[3].ValueType = typeof(string);
                row.Cells[3].Value = istab.abbreviate_en;
                row.Cells[3].Style = new DataGridViewCellStyle()
                {
                    Font = new Font("Tahoma", 9.75f),
                    BackColor = Color.White,
                    ForeColor = Color.Black,
                    SelectionBackColor = Color.White,
                    SelectionForeColor = Color.Black,
                };

                row.Cells[4].ValueType = typeof(string);
                row.Cells[4].Value = istab.typdes_th;
                row.Cells[4].Style = new DataGridViewCellStyle()
                {
                    Font = new Font("Tahoma", 9.75f),
                    BackColor = Color.White,
                    ForeColor = Color.Black,
                    SelectionBackColor = Color.White,
                    SelectionForeColor = Color.Black,
                };

                row.Cells[5].ValueType = typeof(string);
                row.Cells[5].Value = istab.typdes_en;
                row.Cells[5].Style = new DataGridViewCellStyle()
                {
                    Font = new Font("Tahoma", 9.75f),
                    BackColor = Color.White,
                    ForeColor = Color.Black,
                    SelectionBackColor = Color.White,
                    SelectionForeColor = Color.Black,
                };
            }

            this.dgvIstab.FillLine(this.istabs.Count);

            if (selected_item == null)
                return;

            if (this.dgvIstab.Rows.Cast<DataGridViewRow>().Where(t => t.Tag is Istab).Where(t => ((Istab)t.Tag).id == selected_item.id).Count() > 0)
            {
                this.dgvIstab.Rows.Cast<DataGridViewRow>().Where(t => t.Tag is Istab).Where(t => ((Istab)t.Tag).id == selected_item.id).First<DataGridViewRow>().Cells[1].Selected = true;
            }
        }