Exemplo n.º 1
0
        public bool DoSave()
        {
            string sFilename = m_sFilename;

            try
            {
                SaveFileDialogWithEncoding oSaveDlg = new SaveFileDialogWithEncoding();
                oSaveDlg.FileName = sFilename;
                //if (true)
                {
                    oSaveDlg.Title  = "Save Query As";
                    oSaveDlg.Filter =
                        "Query Files (*.sql)|*.sql|" +
                        "All Files (*.*)|*.*";
                }
                // TODO: Fix this.

                /*else
                 * {
                 *      oSaveDlg.Title = "Save Results As";
                 *      oSaveDlg.Filter =
                 *              "Query Files (*.sql)|*.sql|" +
                 *              "All Files (*.*)|*.*";
                 * }*/

                if (oSaveDlg.ShowDialog(Globals.MainForm) == DialogResult.OK)
                {
                    sFilename = oSaveDlg.FileName;
                    if (oSaveDlg.EncodingType == EncodingType.ANSI)
                    {
                        Globals.SaveFile(sFilename, stbMain.Text, System.Text.Encoding.Default);
                    }
                    else if (oSaveDlg.EncodingType == EncodingType.UTF8)
                    {
                        Globals.SaveFile(sFilename, stbMain.Text, System.Text.Encoding.UTF8);
                    }
                    else if (oSaveDlg.EncodingType == EncodingType.Unicode)
                    {
                        Globals.SaveFile(sFilename, stbMain.Text, System.Text.Encoding.Unicode);
                    }

                    m_sFilename = sFilename;
                    UpdateCaption();
                }
            }
            catch (Exception oEx)
            {
                MessageBox.Show(this,
                                "The query text could not be saved to " + sFilename + ".\n\n" +
                                oEx.ToString(), Globals.ksAppTitle,
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return(false);
        }
Exemplo n.º 2
0
        public bool DoSave()
        {
            string sFilename = m_sFilename;

            try
            {
                SaveFileDialogWithEncoding oSaveDlg = new SaveFileDialogWithEncoding();
                oSaveDlg.FileName = sFilename;
                //if (true)
                {
                    oSaveDlg.Title = "Save Query As";
                    oSaveDlg.Filter =
                        "Query Files (*.sql)|*.sql|" +
                        "All Files (*.*)|*.*";
                }
                // TODO: Fix this.
                /*else
                {
                    oSaveDlg.Title = "Save Results As";
                    oSaveDlg.Filter =
                        "Query Files (*.sql)|*.sql|" +
                        "All Files (*.*)|*.*";
                }*/

                if (oSaveDlg.ShowDialog(Globals.MainForm) == DialogResult.OK)
                {
                    sFilename = oSaveDlg.FileName;
                    if (oSaveDlg.EncodingType == EncodingType.ANSI)
                        Globals.SaveFile(sFilename, stbMain.Text, System.Text.Encoding.Default);
                    else if (oSaveDlg.EncodingType == EncodingType.UTF8)
                        Globals.SaveFile(sFilename, stbMain.Text, System.Text.Encoding.UTF8);
                    else if (oSaveDlg.EncodingType == EncodingType.Unicode)
                        Globals.SaveFile(sFilename, stbMain.Text, System.Text.Encoding.Unicode);

                    m_sFilename = sFilename;
                    UpdateCaption();
                }
            }
            catch (Exception oEx)
            {
                MessageBox.Show(this,
                    "The query text could not be saved to " + sFilename + ".\n\n" +
                    oEx.ToString(), Globals.ksAppTitle,
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return false;
        }