Example #1
0
        private void OButtonCancel_Click(object sender, EventArgs e)
        {
            Button ob = (Button)sender;

            dialog.NewSystem oNewSystem = (dialog.NewSystem)ob.Parent.Parent.Parent;
            oNewSystem.Close();
        }
Example #2
0
        private void OButtonOk_Click(object sender, EventArgs e)
        {
            Dictionary <string, string> SystemData = new Dictionary <string, string>();
            Button ob = (Button)sender;

            foreach (var prop in typeof(ImperaturData).GetFields())
            {
                if (prop.Name != "" && prop.FieldType.Equals(typeof(string)))
                {
                    SystemData.Add(prop.Name, ((TextBox)ob.Parent.Controls[prop.Name]).Text);
                }
            }
            dialog.NewSystem oNewSystem = (dialog.NewSystem)ob.Parent.Parent.Parent;
            oNewSystem.SystemData = new ImperaturData
            {
                AcccountDirectory        = SystemData.FirstOrDefault(t => t.Key == "AcccountDirectory").Value,
                CustomerDirectory        = SystemData.FirstOrDefault(t => t.Key == "CustomerDirectory").Value,
                AccountFile              = SystemData.FirstOrDefault(t => t.Key == "AccountFile").Value,
                CustomerFile             = SystemData.FirstOrDefault(t => t.Key == "CustomerFile").Value,
                QuoteDirectory           = SystemData.FirstOrDefault(t => t.Key == "QuoteDirectory").Value,
                QuoteFile                = SystemData.FirstOrDefault(t => t.Key == "QuoteFile").Value,
                SystemCurrency           = SystemData.FirstOrDefault(t => t.Key == "SystemCurrency").Value,
                SystemDirectory          = SystemData.FirstOrDefault(t => t.Key == "SystemDirectory").Value,
                ULR_Quotes               = SystemData.FirstOrDefault(t => t.Key == "ULR_Quotes").Value,
                QuoteRefreshTime         = SystemData.FirstOrDefault(t => t.Key == "QuoteRefreshTime").Value,
                DailyQuoteDirectory      = SystemData.FirstOrDefault(t => t.Key == "DailyQuoteDirectory").Value,
                Exchange                 = SystemData.FirstOrDefault(t => t.Key == "Exchange").Value,
                HistoricalQuoteDirectory = SystemData.FirstOrDefault(t => t.Key == "HistoricalQuoteDirectory").Value,
                HistoricalQuoteFile      = SystemData.FirstOrDefault(t => t.Key == "HistoricalQuoteFile").Value,
                OrderDirectory           = SystemData.FirstOrDefault(t => t.Key == "OrderDirectory").Value
            };
            //all fields must be filled in!
            bool AllFieldsOk = true;

            foreach (var prop in typeof(ImperaturData).GetFields())
            {
                if (prop.Name != "" && prop.FieldType.Equals(typeof(string))
                    &&
                    (
                        typeof(ImperaturData).GetFields().FirstOrDefault(t => t.Name == prop.Name).GetValue(oNewSystem.SystemData) != null
                        &&
                        typeof(ImperaturData).GetFields().FirstOrDefault(t => t.Name == prop.Name).GetValue(oNewSystem.SystemData).ToString().Trim().Length == 0
                    )
                    ||
                    typeof(ImperaturData).GetFields().FirstOrDefault(t => t.Name == prop.Name).GetValue(oNewSystem.SystemData) == null
                    )
                {
                    MessageBox.Show("All fields must be filled!");
                    AllFieldsOk = false;
                    break;
                }
            }
            if (AllFieldsOk)
            {
                oNewSystem.DialogResult = DialogResult.OK;
                oNewSystem.Close();
            }
            else
            {
                oNewSystem.DialogResult = DialogResult.None;
            }
        }