コード例 #1
0
ファイル: Main.cs プロジェクト: taving/BenMAP-CE
 private void btnOpenFile_Click(object sender, EventArgs e)
 {
     try
     {
         string msg = string.Empty;
         string tip = string.Empty;
         if (CommonClass.LstAsynchronizationStates != null && CommonClass.LstAsynchronizationStates.Count > 0)
         {
             msg = "Baseline or control air quality surface is being created. Please wait.";
             tip = "Please wait";
             MessageBox.Show(msg, tip, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         if (_currentForm != null)
         {
             BenMAP frm = _currentForm as BenMAP;
             if (frm != null)
             {
                 frm.OpenProject();
                 if (frm.ProjFileName != "")
                 {
                     _projFileName = frm.ProjFileName;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.LogError(ex);
     }
 }
コード例 #2
0
ファイル: Main.cs プロジェクト: taving/BenMAP-CE
        void toolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CommonClass.MainSetup != null && ((sender as ToolStripMenuItem).Tag as BenMAPSetup).SetupID == CommonClass.MainSetup.SetupID)
            {
                return;
            }
            string msg = string.Empty;
            string tip = string.Empty;

            if (CommonClass.LstAsynchronizationStates != null && CommonClass.LstAsynchronizationStates.Count > 0)
            {
                msg = "Baseline or control air quality surface is being created. Please wait.";
                tip = "Please wait";
                MessageBox.Show(msg, tip, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (CommonClass.LstPollutant != null && CommonClass.LstPollutant.Count > 0 && MessageBox.Show("Save the current case before switching to another case?", "Question", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                mnuSaveAs_Click(sender, e);
                if (!_hasSave)
                {
                    return;
                }
            }
            CommonClass.MainSetup   = (sender as ToolStripMenuItem).Tag as BenMAPSetup;
            CommonClass.ManageSetup = (sender as ToolStripMenuItem).Tag as BenMAPSetup;
            this.Status             = "Current Setup: " + CommonClass.MainSetup.SetupName;
            lblStatus.Text          = this.Status; mnuActiveSetup.Text = (sender as ToolStripMenuItem).Text;
            BenMAP frm = _currentForm as BenMAP;

            frm.OpenFile();
            CommonClass.lstPollutantAll = Grid.GridCommon.getAllPollutant(CommonClass.MainSetup.SetupID);
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: taving/BenMAP-CE
        private void mnuRecentFile0_Click(object sender, EventArgs e)
        {
            try
            {
                ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
                if (menuItem == null)
                {
                    return;
                }
                string tag  = menuItem.Tag.ToString();
                string path = "";

                if (_currentForm != null)
                {
                    BenMAP frm = _currentForm as BenMAP;
                    if (frm != null)
                    {
                        switch (tag)
                        {
                        case "China Case":
                            CommonClass.ActiveSetup = "China";
                            path = Application.StartupPath + @"\Configs\ParamsTree_China.xml";
                            break;

                        case "USA Case":
                            CommonClass.ActiveSetup = "USA";
                            path = Application.StartupPath + @"\Configs\ParamsTree_USA.xml";
                            break;

                        default:
                            break;
                        }
                        frm.OpenFile(path);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
            }
        }
コード例 #4
0
ファイル: Main.cs プロジェクト: taving/BenMAP-CE
 private void btnNewFile_Click(object sender, EventArgs e)
 {
     try
     {
         string msg = string.Empty;
         string tip = string.Empty;
         if (CommonClass.LstAsynchronizationStates != null && CommonClass.LstAsynchronizationStates.Count > 0)
         {
             msg = "Baseline or control air quality surface is being created. Please wait.";
             tip = "Please wait";
             MessageBox.Show(msg, tip, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         if (_currentForm != null)
         {
             BenMAP frm = _currentForm as BenMAP;
             if (frm != null)
             {
                 if (CommonClass.LstPollutant != null && CommonClass.LstPollutant.Count > 0 && MessageBox.Show("Save the current case before switching to another case?", "Question", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                 {
                     mnuSaveAs_Click(sender, e);
                     if (_hasSave)
                     {
                         frm.OpenFile();
                         _projFileName = "";
                     }
                 }
                 else
                 {
                     frm.OpenFile();
                     _projFileName = "";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.LogError(ex);
     }
 }
コード例 #5
0
ファイル: Main.cs プロジェクト: taving/BenMAP-CE
        private void mnuModifySetup_Click(object sender, EventArgs e)
        {
            ManageSetup  frm          = new ManageSetup();
            DialogResult dialogResult = frm.ShowDialog();

            if (_currentForm != null)
            {
                BenMAP frmBenMAP = _currentForm as BenMAP;
                if (frmBenMAP != null)
                {
                    frmBenMAP.InitAggregationAndRegionList();
                }
            }


            string commandText = "select SetupID,SetupName from Setups order by SetupID";

            ESIL.DBUtility.FireBirdHelperBase fb = new ESIL.DBUtility.ESILFireBirdHelper();
            System.Data.DataSet ds = fb.ExecuteDataset(CommonClass.Connection, CommandType.Text, commandText);

            mnuActiveSetup.DropDownItems.Clear();

            foreach (DataRow drSetup in ds.Tables[0].Rows)
            {
                BenMAPSetup benMAPSetupIn = new BenMAPSetup()
                {
                    SetupID   = Convert.ToInt32(drSetup["SetupID"]),
                    SetupName = drSetup["SetupName"].ToString()
                };
                ToolStripMenuItem toolStripMenuItem = new ToolStripMenuItem();
                toolStripMenuItem.Text   = drSetup["SetupName"].ToString();
                toolStripMenuItem.Tag    = benMAPSetupIn;
                toolStripMenuItem.Click += new EventHandler(toolStripMenuItem_Click);
                mnuActiveSetup.DropDownItems.Add(toolStripMenuItem);
            }
            DataRow[] dr = ds.Tables[0].Select("SETUPNAME ='" + mnuActiveSetup.Text + "'");
            if (dr.Count() <= 0 && ds.Tables[0].Rows.Count > 0)
            {
                mnuActiveSetup.Text = ds.Tables[0].Rows[0]["SetupName"].ToString();
            }

            CommonClass.lstPollutantAll = Grid.GridCommon.getAllPollutant(CommonClass.MainSetup.SetupID);
            DataSourceCommonClass._dicSeasonStaticsAll = null;
            bool isDel = false;

            if (CommonClass.LstPollutant != null && CommonClass.LstPollutant.Count > 0)
            {
                for (int iPollutant = 0; iPollutant < CommonClass.LstPollutant.Count; iPollutant++)
                {
                    try
                    {
                        CommonClass.LstPollutant[iPollutant] = CommonClass.lstPollutantAll.Where(p => p.PollutantID == CommonClass.LstPollutant[iPollutant].PollutantID).First();
                    }
                    catch
                    {
                        isDel = true;
                        break;
                    }
                }
            }
            if (isDel)
            {
                if (_currentForm != null)
                {
                    BenMAP frmBenMAP = _currentForm as BenMAP;
                    if (frmBenMAP != null)
                    {
                        if (CommonClass.LstPollutant != null && CommonClass.LstPollutant.Count > 0 && MessageBox.Show("The selected pollutant no longer exists in the database. Please select other pollutants. Save the current case before switching to another case?", "Question", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                        {
                            mnuSaveAs_Click(sender, e);
                            if (_hasSave)
                            {
                                frmBenMAP.OpenFile();
                                _projFileName = "";
                            }
                        }
                        else
                        {
                            frmBenMAP.OpenFile();
                            _projFileName = "";
                        }
                    }
                }
                return;
            }
            if (CommonClass.LstBaseControlGroup != null && CommonClass.LstBaseControlGroup.Count > 0)
            {
                foreach (BaseControlGroup b in CommonClass.LstBaseControlGroup)
                {
                    b.Pollutant = CommonClass.lstPollutantAll.Where(p => p.PollutantID == b.Pollutant.PollutantID).First();
                    if (b.Base != null && b.Base.Pollutant != null)
                    {
                        b.Base.Pollutant = b.Pollutant;
                    }
                    if (b.Control != null && b.Control.Pollutant != null)
                    {
                        b.Control.Pollutant = b.Pollutant;
                    }
                }
            }
            if (CommonClass.BaseControlCRSelectFunction != null && CommonClass.BaseControlCRSelectFunction.lstCRSelectFunction != null && CommonClass.BaseControlCRSelectFunction.lstCRSelectFunction.Count > 0)
            {
                foreach (CRSelectFunction cr in CommonClass.BaseControlCRSelectFunction.lstCRSelectFunction)
                {
                    List <BenMAPPollutant> lstpollutant = CommonClass.lstPollutantAll.Where(p => p.PollutantID == cr.BenMAPHealthImpactFunction.Pollutant.PollutantID).ToList();
                    if (lstpollutant != null && lstpollutant.Count > 0)
                    {
                        cr.BenMAPHealthImpactFunction.Pollutant = lstpollutant.First();
                    }
                }
            }
        }
コード例 #6
0
ファイル: Main.cs プロジェクト: taving/BenMAP-CE
        public Main()
        {
            try
            {
                InitializeComponent();
                CheckFirebirdAndStartFirebird();
                _baseFormTitle = this.Text + Assembly.GetExecutingAssembly().GetName().Version.ToString().Substring(0, Assembly.GetExecutingAssembly().GetName().Version.ToString().Count() - 2); mnuOverview.Text = "Quick-Start Guide"; this.Text = _baseFormTitle;

                string sPicName = "";
                CommonClass.ActiveSetup = "USA";
                string commandText = "select SetupID,SetupName from Setups order by SetupID";
                ESIL.DBUtility.FireBirdHelperBase fb = new ESIL.DBUtility.ESILFireBirdHelper();
                System.Data.DataSet ds = fb.ExecuteDataset(CommonClass.Connection, CommandType.Text, commandText);

                string iniPath      = CommonClass.ResultFilePath + @"\BenMAP.ini";
                string defaultSetup = "United States";
                if (System.IO.File.Exists(iniPath))
                {
                    defaultSetup = CommonClass.IniReadValue("appSettings", "DefaultSetup", iniPath);
                }
                else
                {
                    CommonClass.IniWriteValue("appSettings", "IsShowStart", "T", iniPath);
                    CommonClass.IniWriteValue("appSettings", "IsShowExit", "T", iniPath);
                    CommonClass.IniWriteValue("appSettings", "DefaultSetup", "United States", iniPath);
                }
                DataRow[] drs = ds.Tables[0].Select("SetupName='" + defaultSetup + "'");
                DataRow   dr;
                if (drs != null && drs.Count() > 0)
                {
                    dr = drs[0];
                }
                else
                {
                    dr = ds.Tables[0].Rows[0];
                    CommonClass.IniWriteValue("appSettings", "DefaultSetup", dr["SetupName"].ToString(), iniPath);
                }
                BenMAPSetup benMAPSetup = new BenMAPSetup()
                {
                    SetupID   = Convert.ToInt32(dr["SetupID"]),
                    SetupName = dr["SetupName"].ToString()
                };
                mnuActiveSetup.DropDownItems.Clear();

                foreach (DataRow drSetup in ds.Tables[0].Rows)
                {
                    BenMAPSetup benMAPSetupIn = new BenMAPSetup()
                    {
                        SetupID   = Convert.ToInt32(drSetup["SetupID"]),
                        SetupName = drSetup["SetupName"].ToString()
                    };
                    ToolStripMenuItem toolStripMenuItem = new ToolStripMenuItem();
                    toolStripMenuItem.Text   = drSetup["SetupName"].ToString();
                    toolStripMenuItem.Tag    = benMAPSetupIn;
                    toolStripMenuItem.Click += new EventHandler(toolStripMenuItem_Click);
                    mnuActiveSetup.DropDownItems.Add(toolStripMenuItem);
                }
                if (mnuActiveSetup.DropDownItems.Count > 0)
                {
                    mnuActiveSetup.Text = dr["SetupName"].ToString();
                }
                CommonClass.MainSetup   = benMAPSetup;
                CommonClass.ManageSetup = benMAPSetup;

                CommonClass.lstPollutantAll = Grid.GridCommon.getAllPollutant(CommonClass.MainSetup.SetupID);
                if (CommonClass.InputParams == null || CommonClass.InputParams.Length == 0)
                {
                    StartPage startFrm = new StartPage();
                    startFrm.ShowDialog();
                }
                else if (CommonClass.InputParams[0].ToLower().Contains(".ctlx"))
                {
                    this.Hide();
                    this.ShowInTaskbar = false;
                    this.WindowState   = FormWindowState.Minimized;
                    return;
                }
                LoadForm(new BenMAP(sPicName));
                InitRecentFile();



                CommonClass.FormChangedStat -= SetCurrentStat;
                CommonClass.FormChangedStat += SetCurrentStat;

                CommonClass.FormChangedSetup -= SetCurrentSetup;
                CommonClass.FormChangedSetup += SetCurrentSetup;



                if (_currentForm != null)
                {
                    BenMAP frm = _currentForm as BenMAP;
                    if (frm != null)
                    {
                        frm.OpenFile();
                        frm.loadInputParamProject();
                    }
                    frm.mainFrm = this;
                }
                this.Status    = "Current Setup: " + CommonClass.MainSetup.SetupName;
                lblStatus.Text = this.Status;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
            }
        }