Example #1
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     DatabaseManager dbManager = new DatabaseManager();
     try {
         if (new Login(dbManager).ShowDialog() == DialogResult.OK)
         {
             var logging_form = new FormLogging();
             OTCDataSet dataset = new OTCDataSet("otc", dbManager);
             logging_form.Close();
             Application.Run(new MainWindow(dataset));
         }
     }
     catch (StackExchange.Redis.RedisConnectionException e)
     {
         MessageBox.Show(string.Format("Redis连接错误:请重新登录。\n错误信息:{0}", e.Message), "错误");
         if (new Login(dbManager).ShowDialog() == DialogResult.OK)
         {
             OTCDataSet dataset = new OTCDataSet("otc", dbManager);
             Application.Run(new MainWindow(dataset));
         }
     }
     catch (MySql.Data.MySqlClient.MySqlException e)
     {
         MessageBox.Show(string.Format("Mysql错误。\n错误信息:{0}", e.Message), "错误");
         if (new Login(dbManager).ShowDialog() == DialogResult.OK)
         {
             OTCDataSet dataset = new OTCDataSet("otc", dbManager);
             Application.Run(new MainWindow(dataset));
         }
     }
 }
Example #2
0
 public OTCDataSet(DatabaseManager dm) : this()
 {
     this.dbManager = dm;
     this.sql_connection = dm.GetSQLConnection();
     this.redis_connection = dm.GetRedisConnection();
     this.redis_db = CreateRedisConnection();
     GetData();
 }
 private void buttonOK_Click(object sender, EventArgs e)
 {
     decimal commision = 0;
     decimal margin = 0;
     decimal multiplier = 0;
     decimal volatility = 0;
     if (String.IsNullOrEmpty(this.textBoxFuturesContractCode.Text))
     {
         MessageBox.Show("期货合约代码不能为空。", "错误");
     }
     else if (String.IsNullOrEmpty(this.comboBoxUnderlyingCode.Text))
     {
         MessageBox.Show("标的不能为空。", "错误");
     }
     else if (!decimal.TryParse(this.textBoxCommission.Text, out commision))
     {
         MessageBox.Show("手续费格式错误。", "错误");
     }
     else if (!decimal.TryParse(this.textBoxMarginRate.Text, out margin))
     {
         MessageBox.Show("保证金格式错误。", "错误");
     }
     else if (!decimal.TryParse(this.textBoxMultiplier.Text, out multiplier))
     {
         MessageBox.Show("合约乘数格式错误。", "错误");
     }
     else if (!decimal.TryParse(this.textBoxVolatility.Text, out volatility))
     {
         MessageBox.Show("波动率格式错误。", "错误");
     }
     else
     {
         DatabaseManager dm = new DatabaseManager();
         var conn = dm.GetRedisConnection();
         var db = conn.GetDatabase();
         if (db.KeyExists(this.textBoxFuturesContractCode.Text))
         {
             double pre_settle = double.Parse(db.HashGet(this.textBoxFuturesContractCode.Text, "PreSettlementPrice").ToString());
             string commission_mode = this.radioButtonAbsCommission.Checked ? "abs" : "pct";
             table.Rows.Add(this.textBoxFuturesContractCode.Text, this.comboBoxUnderlyingCode.Text.Split('-')[1], commission_mode, commision, margin, pre_settle, multiplier, volatility, false);
             this.dataset.Commit("futures_contracts");
             this.dataset.Update("futures_contracts");
             this.dataset.Update("futures_contracts_view");
             this.Close();
         }
         else
         {
             MessageBox.Show("期货合约不存在。", "错误");
         }
     }
 }
Example #4
0
 public Login(DatabaseManager dm)
 {
     InitializeComponent();
     this.dbManager = dm;
     String s = Properties.Settings.Default.Password;
     this.textBoxUserName.Text = Properties.Settings.Default.UserName;
     if (String.IsNullOrEmpty(Properties.Settings.Default.Password))
     {
         this.textBoxPassword.Text = "";
     }
     else
     {
         this.textBoxPassword.Text = DataProtection.DecryptString(Properties.Settings.Default.Password);
     }
     this.checkBoxRememberLoginInfo.Checked = Properties.Settings.Default.isRememberPasswordChecked;
 }
Example #5
0
 public OTCDataSet(String name, DatabaseManager dm) : this(dm)
 {
     base.DataSetName = name;
 }