private void BtnSubmit_Click(object sender, EventArgs e)
        {
            //get column values where MK not null or empty
            DataTable dt = uIUtility.SubmitChanges();

            if (dt.Rows.Count > 0)
            {
                //send to web service
                frmCompanyCodeListController oController = new frmCompanyCodeListController();
                try
                {
                    DataTable result = oController.Submit(dt, out uIUtility.MetaData);

                    //update data grid view
                    uIUtility.UpdateReturnedresults(result);
                }
                catch (System.TimeoutException)
                {
                    MetroMessageBox.Show(this, "\n" + Messages.General.ServerTimeOut, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (System.Net.WebException)
                {
                    MetroMessageBox.Show(this, "\n" + Messages.General.NoConnection, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    Utility.WriteErrorLog(ex.Message, ex, false);
                    MetroMessageBox.Show(this, "\n" + Messages.General.ThereWasAnError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void BtnGeneratePassword_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < dgvList.Rows.Count; i++)
                {
                    string MK_Value = dgvList.Rows[i].Cells["colMK"].Value == null ? null : dgvList.Rows[i].Cells["colMK"].Value.ToString();
                    if (MK_Value == "I" || MK_Value == "C" || MK_Value == "M")
                    {
                        frmCompanyCodeListController companyCodeList = new frmCompanyCodeListController();
                        DataTable dt = companyCodeList.GetPassword();

                        //update datagrid
                        dgvList.Rows[i].Cells["colPASSWORD_"].Value                = dt.Rows[0]["PASSWORD"].ToString();
                        dgvList.Rows[i].Cells["colPASSWORD_SET_DATE"].Value        = dt.Rows[0]["PASSWORD_SET_DATE"].ToString();
                        dgvList.Rows[i].Cells["colPASSWORD_EXPIRATION_DATE"].Value = dt.Rows[0]["PASSWORD_EXPIRATION_DATE"].ToString();
                    }
                }
            }
            catch (System.TimeoutException)
            {
                MetroMessageBox.Show(this, "\n" + Messages.General.ServerTimeOut, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (System.Net.WebException)
            {
                MetroMessageBox.Show(this, "\n" + Messages.General.NoConnection, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                Utility.WriteErrorLog(ex.Message, ex, false);
                MetroMessageBox.Show(this, "\n" + Messages.General.ThereWasAnError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private async void BtnSendMail_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = uIUtility.GetCheckedValuesForMail();
                if (dt.Rows.Count > 0)
                {
                    var confirmResult = MetroMessageBox.Show(this, "\n" + "メール送信しますか?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    if (confirmResult == DialogResult.OK)
                    {
                        //Show mail progress message
                        Thread mailthread = new Thread(new ThreadStart(ShowMailLoading));
                        mailthread.Start();
                        //call mail send method from web service
                        frmCompanyCodeListController companyCodeList = new frmCompanyCodeListController();
                        DataTable result = await companyCodeList.SendMail(dt);

                        //update data grid view
                        uIUtility.UpdateReturnedresults(result);

                        //close mail dialog
                        mailthread.Abort();
                    }
                }
            }
            catch (System.TimeoutException)
            {
                MetroMessageBox.Show(this, "\n" + Messages.General.ServerTimeOut, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (System.Net.WebException)
            {
                MetroMessageBox.Show(this, "\n" + Messages.General.NoConnection, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                Utility.WriteErrorLog(ex.Message, ex, false);
                MetroMessageBox.Show(this, "\n" + Messages.General.ThereWasAnError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void BindGrid()
        {
            try
            {
                string company_no_box, company_name, email;

                if (!CheckUtility.SearchConditionCheck(this, lblCompanyNoBox.Text, txtCompanyNoBox.Text, false, Utility.DataType.HALF_KANA_ALPHA_NUMERIC, 10, 0))
                {
                    return;
                }

                if (!CheckUtility.SearchConditionCheck(this, lblCompanyName.Text, txtCompanyName.Text, false, Utility.DataType.FULL_WIDTH, 80, 0))
                {
                    return;
                }

                if (!CheckUtility.SearchConditionCheck(this, lblEmail.Text, txtEmail.Text, false, Utility.DataType.HALF_ALPHA_NUMERIC, 255, 0))
                {
                    return;
                }
                company_no_box = txtCompanyNoBox.Text.Trim();
                company_name   = txtCompanyName.Text.Trim();
                email          = txtEmail.Text.Trim();

                frmCompanyCodeListController oController = new frmCompanyCodeListController();

                DataTable dt = oController.GetCompanyCodeList(company_no_box, company_name, email, uIUtility.MetaData.Offset, uIUtility.MetaData.Limit, out uIUtility.MetaData);
                if (dt.Rows.Count > 0)
                {
                    uIUtility.dtList   = dt;
                    dgvList.DataSource = uIUtility.dtList;
                    uIUtility.dtOrigin = uIUtility.dtList.Copy();

                    //pagination
                    uIUtility.CalculatePagination(lblcurrentPage, lblTotalPages, lblTotalRecords);
                }
                else
                {
                    //clear data except headers
                    uIUtility.ClearDataGrid();
                    uIUtility.CalculatePagination(lblcurrentPage, lblTotalPages, lblTotalRecords);
                }

                uIUtility.CheckPagination(btnFirst, btnPrev, btnNext, btnLast, lblcurrentPage.Text, lblTotalPages.Text);

                //check for disable flag
                uIUtility.CheckForDisableField();
                uIUtility.FormatUpdatedat();
            }
            catch (System.TimeoutException)
            {
                MetroMessageBox.Show(this, "\n" + Messages.General.ServerTimeOut, "Search Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (System.Net.WebException)
            {
                MetroMessageBox.Show(this, "\n" + Messages.General.NoConnection, "Search Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                Utility.WriteErrorLog(ex.Message, ex, false);
                MetroMessageBox.Show(this, "\n" + Messages.General.ThereWasAnError, "Search Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }