private void FrmPreviewScreen_FormClosing(object sender, FormClosingEventArgs e)
        {
            frmRegisterCompleteNotificationController oController = new frmRegisterCompleteNotificationController();

            oController.DeleteTempFiles(FILENAME);
            pdfDocumentViewer.Dispose();
            this.DialogResult = Dialog;
        }
        private void BindGrid()
        {
            try
            {
                //assign search keywords
                txtCompanyNoBox.Text       = COMPANY_NO_BOX;
                txtCompanyName.Text        = COMPANY_NAME;
                txtQuotationIssueDate.Text = QUOTATION_DATE;
                txtOrderDate.Text          = ORDER_DATE;
                txtRegisterCompleteNotificationDate.Text = COMPLETION_NOTIFICATION_DATE;

                frmRegisterCompleteNotificationController oController = new frmRegisterCompleteNotificationController();

                DataTable dt = oController.GetScreenData(COMPANY_NO_BOX, out uIUtility.MetaData);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        txtEDIAccount.Text             = row["EDI_ACCOUNT"].ToString();
                        txtDestinationMailAddress.Text = row["EMAIL_ADDRESS"].ToString();
                    }
                }
            }
            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);
            }
        }
        private async void BtnPreview_Click(object sender, EventArgs e)
        {
            if (CheckUtility.SearchConditionCheck(this, lblDestinationMailAddress.Text, txtDestinationMailAddress.Text, false, Utility.DataType.EMAIL, 255, 0))
            {
                frmRegisterCompleteNotificationController oController = new frmRegisterCompleteNotificationController();
                try
                {
                    DataTable result = oController.PreviewFunction(txtCompanyName.Text, txtCompanyNoBox.Text, REQ_SEQ, txtEDIAccount.Text);

                    string return_message = "";
                    try
                    {
                        return_message = result.Rows[0]["Message"].ToString();
                    }
                    catch (Exception)
                    {
                    }
                    string FILENAME = "";
                    if (string.IsNullOrEmpty(return_message))
                    {
                        FILENAME = result.Rows[0]["FILENAME"].ToString();
                        MetroMessageBox.Show(this, "\n" + JimugoMessages.I000WB001, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MetroMessageBox.Show(this, "\n" + return_message, "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    DataTable dt = DTParameter(txtCompanyNoBox.Text, REQ_SEQ, QUOTATION_DATE, ORDER_DATE, COMPLETION_NOTIFICATION_DATE, COMPANY_NAME, txtDestinationMailAddress.Text, txtEDIAccount.Text, FILENAME);

                    #region CallPreviewScreen
                    string temp_deirectory = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + @"/Temp";

                    if (!Directory.Exists(temp_deirectory))
                    {
                        Directory.CreateDirectory(temp_deirectory);
                    }

                    //delete temp files
                    Utility.DeleteFiles(temp_deirectory);

                    string destinationpath = temp_deirectory + "/" + FILENAME;
                    btnPreview.Enabled = false;
                    bool success = await Core.WebUtility.Download(Properties.Settings.Default.GetTempFile + "?FILENAME=" + FILENAME, destinationpath);

                    if (success)
                    {
                        frmRegisterCompleteNotificationPreview frm = new frmRegisterCompleteNotificationPreview(dt);
                        frm.ShowDialog();
                        this.Show();
                        UPDATED_AT     = frm.UPDATED_AT;
                        UPDATED_AT_RAW = frm.UPDATED_AT_RAW;
                        COMPLETION_NOTIFICATION_DATE = txtRegisterCompleteNotificationDate.Text.Trim();
                        Dialog = DialogResult.OK;
                        this.BringToFront();
                    }
                    btnPreview.Enabled = true;
                    #endregion
                }
                catch (Exception ex)
                {
                    Utility.WriteErrorLog(ex.Message, ex, false);
                }
            }
        }