Пример #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();
        }
Пример #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;
            }
        }
Пример #3
0
        private ImperaturData CreateNewImperaturMarket(ImperaturData oNewSystem)
        {
            using (var form = new dialog.NewSystem())
            {
                form.Icon = this.Icon;
                GroupBox oB = new GroupBox()
                {
                    Dock    = DockStyle.Fill,
                    Text    = "Create new System",
                    Name    = "gp",
                    Visible = true,
                    Padding = new Padding()
                    {
                        All = 20
                    },
                    Margin = new Padding()
                    {
                        All = 20
                    },
                    Bounds = form.Bounds
                };

                TableLayoutPanel tlp = new TableLayoutPanel
                {
                    Name         = "tlp",
                    Dock         = DockStyle.Fill,
                    RowCount     = typeof(ImperaturData).GetFields().Count() + 1,
                    ColumnCount  = 2,
                    Visible      = true,
                    AutoSize     = true,
                    AutoSizeMode = AutoSizeMode.GrowAndShrink,
                };

                int indexcount = 0;
                foreach (var prop in typeof(ImperaturData).GetFields())
                {
                    if (prop.Name != "")
                    {
                        if (prop.FieldType.Equals(typeof(string)))
                        {
                            string Value = prop.Name.Equals("SystemDirectory") ? SystemLocation : typeof(ImperaturDataStandard).GetFields().FirstOrDefault(t => t.Name == prop.Name).GetValue(null).ToString();
                            tlp.Controls.Add(new TextBox()
                            {
                                Text =
                                    Value
                                ,
                                Name     = prop.Name,
                                Anchor   = AnchorStyles.Left,
                                Width    = 300,
                                AutoSize = true,
                                ReadOnly = prop.Name.Equals("SystemDirectory") && SystemLocation.Length > 0 ? true : false
                            }, 1, indexcount);
                            tlp.Controls.Add(new Label()
                            {
                                Text = prop.Name, Anchor = AnchorStyles.Left, AutoSize = true
                            }, 0, indexcount);
                        }
                    }
                    indexcount++;
                }

                Button oButtonOk = new Button()
                {
                    Name         = "buttonok",
                    Text         = "OK",
                    AutoSizeMode = AutoSizeMode.GrowAndShrink,
                    DialogResult = DialogResult.OK
                };

                Button oButtonCancel = new Button()
                {
                    Name         = "buttoncancel",
                    Text         = "Cancel",
                    AutoSizeMode = AutoSizeMode.GrowAndShrink
                };

                oButtonOk.Click     += OButtonOk_Click;
                oButtonCancel.Click += OButtonCancel_Click;

                tlp.Controls.Add(oButtonOk, 0, indexcount);
                tlp.Controls.Add(oButtonCancel, 1, indexcount);

                oB.Controls.Add(tlp);
                form.Controls.Add(oB);

                form.Height = tlp.Height;


                try
                {
                    var result = form.ShowDialog();
                    while (!result.Equals(DialogResult.OK) && !result.Equals(DialogResult.Cancel))
                    {
                    }

                    if (result == DialogResult.OK)
                    {
                        oNewSystem = form.SystemData;
                    }
                    else
                    {
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    int gg = 0;
                }
            }

            return(oNewSystem);
        }