private bool Form_LoadControl(object sender, object data) { if (data is DialogType) { DialogType = (DialogType)data; if (DialogType == DialogType.Modify) { this.acSecurity.Enabled = false; } this.StartPosition = FormStartPosition.CenterParent; } acSecurity.SetDropdownList(this.lbDropdown); _securityInfoList = SecurityInfoManager.Instance.Get(); foreach (var secuInfo in _securityInfoList) { AutoItem autoItem = new AutoItem { Id = secuInfo.SecuCode, Name = secuInfo.SecuName, }; _dataSource.Add(autoItem); } acSecurity.AutoDataSource = _dataSource; return(true); }
private bool Form_LoadControl(object sender, object data) { //FuturesContracts acFuturesContracts.SetDropdownList(lbDropdown); List <SecurityItem> itemList = FuturesContractManager.Instance.GetAll(); //_futureBLL.GetAll(); IList <AutoItem> dataSource = new List <AutoItem>(); foreach (var fcItem in itemList) { AutoItem autoItem = new AutoItem { Id = fcItem.SecuCode, Name = fcItem.SecuName }; dataSource.Add(autoItem); } acFuturesContracts.AutoDataSource = dataSource; //accounttype cbAccountType.Enabled = false; var accoutTypes = ConfigManager.Instance.GetComboConfig().GetComboOption("accounttype"); ComboBoxUtil.SetComboBox(this.cbAccountType, accoutTypes); //Portfolio combobox LoadPortfolio(); //Load stock template combobox LoadStockTemplate(); return(true); }
static List <AutoObject> DataReaderToAutoObject(SqlDataReader reader) { List <AutoObject> lst = new List <AutoObject>(); while (reader.Read()) { List <AutoItem> items = new List <AutoItem>(); for (int i = 0; i < reader.FieldCount; i++) { AutoItem p = new AutoItem(); p.CSharpType = reader.GetFieldType(i).FullName; p.Name = reader.GetName(i); //p.SqlType = Lambda.Framework.BMIConvert.GetSqlTypeFromStringType(reader.GetDataTypeName(i)); //p.SqlType = reader.GetDataTypeName(i); var value = reader.GetValue(i); p.Value = value; if (p.Value == DBNull.Value) { p.Value = null; } items.Add(p); } AutoObject d = new AutoObject(); d.Items = items; lst.Add(d); } reader.Close(); return(lst); }
/// <summary> /// listbox各项绘制,为了可以调整Item的高度 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { e.DrawBackground(); e.DrawFocusRectangle(); AutoItem item = (sender as ListBox).Items[e.Index] as AutoItem; string text = string.Format("{0} {1}", item.Id, item.Name); e.Graphics.DrawString(text, e.Font, new SolidBrush(e.ForeColor), e.Bounds); }
public AutoItem GetCurrentItem() { AutoItem autoItem = new AutoItem(); autoItem.Id = this.tbInputId.Text.Trim(); autoItem.Name = this.tbName.Text.Trim(); return(autoItem); }
private void InitControlData(TemplateStock stock) { AutoItem autoItem = new AutoItem { Id = stock.SecuCode, Name = stock.SecuName }; acSecurity.SetCurrentItem(autoItem); tbAmount.Text = string.Format("{0}", stock.Amount); tbSettingWeight.Text = string.Format("{0}", stock.SettingWeight); }
private void AutoComplete_SecuIn_SelectChangedItem(object sender, AutoItem data) { if (sender == null || data == null) { return; } if (string.IsNullOrEmpty(data.Id)) { return; } List <SecurityItem> secuItemList = new List <SecurityItem>(); var inItem = _secuInfoList.Find(p => p.SecuCode.Equals(data.Id)); if (inItem != null) { secuItemList.Add(inItem); } var outItem = _secuInfoList.Find(p => p.SecuCode.Equals(_originItem.SecuCode)); if (outItem != null) { secuItemList.Add(outItem); } //QuoteCenter.Instance.Query(secuItemList); var inPriceData = QuoteCenter.Instance.GetMarketData(inItem); var outPriceData = QuoteCenter.Instance.GetMarketData(outItem); int inAmount = 0; if (inPriceData != null && outPriceData != null) { SetPrice(inPriceData, this.tbInPrice); SetPrice(outPriceData, this.tbOutPrice); if (outPriceData.CurrentPrice > 0) { var temp = _originItem.AvailableAmount * inPriceData.CurrentPrice / outPriceData.CurrentPrice; inAmount = AmountRoundUtil.Round((int)temp); } } if (inAmount > 0) { this.tbInAmount.Text = string.Format("{0}", inAmount); } }
private void LoadChangeOut(ClosePositionSecurityItem closeSecuItem) { AutoItem autoItem = new AutoItem { Id = closeSecuItem.SecuCode, Name = closeSecuItem.SecuName }; this.acSecuOut.SetCurrentItem(autoItem); string longShort = string.Format("{0}", (int)closeSecuItem.PositionType); ComboBoxUtil.SetComboBoxSelect(this.cbOutDirection, longShort); //股票设置调出为卖出,调入为买入 //股指期货设置调出为买入平仓,调入为卖出开仓 EntrustDirection eOutDirection; EntrustDirection eInDirection; if (closeSecuItem.SecuType == Model.SecurityInfo.SecurityType.Stock) { eOutDirection = EntrustDirection.Sell; eInDirection = EntrustDirection.Buy; } else if (closeSecuItem.SecuType == Model.SecurityInfo.SecurityType.Futures) { eOutDirection = EntrustDirection.Buy; eInDirection = EntrustDirection.Sell; } else { eOutDirection = EntrustDirection.Sell; eInDirection = EntrustDirection.Buy; } string outDirection = string.Format("{0}", (int)eOutDirection); ComboBoxUtil.SetComboBoxSelect(this.cbOutDirection, outDirection); this.tbOutAmount.Text = string.Format("{0}", closeSecuItem.AvailableAmount); //设置调入 string inDirection = string.Format("{0}", (int)eInDirection); ComboBoxUtil.SetComboBoxSelect(this.cbInDirection, inDirection); }
private void LoadAutoComplete(ClosePositionSecurityItem closeSecuItem) { IList <AutoItem> dataSource = new List <AutoItem>(); var matchItems = _secuInfoList.Where(p => p.SecuType == closeSecuItem.SecuType && !p.SecuCode.Equals(closeSecuItem.SecuCode)).ToList(); foreach (var item in matchItems) { AutoItem autoItem = new AutoItem { Id = item.SecuCode, Name = item.SecuName, }; dataSource.Add(autoItem); } this.acSecuOut.AutoDataSource = dataSource; this.acSecuIn.AutoDataSource = dataSource; }
public static SqlParameter ToSqlParameter(this AutoItem param) { if (param == null) { return(null); } SqlParameter sqlPara = new SqlParameter(); sqlPara.ParameterName = param.Name; sqlPara.Value = param.Value; if (sqlPara.Value == null) { sqlPara.Value = DBNull.Value; } if (param.SqlType == SqlDbType.Timestamp) { sqlPara.Direction = ParameterDirection.InputOutput; } sqlPara.SqlDbType = param.SqlType; return(sqlPara); }
/// <summary> /// listbox的点击事件,为了给textbox赋值 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListBox_Click(object sender, System.EventArgs e) { ListBox listBox = sender as ListBox; if (listBox == null) { return; } AutoItem item = listBox.SelectedItem as AutoItem; this.tbInputId.Text = item.Id; this.tbName.Text = item.Name; listBox.Visible = false; //光标点位到最后 this.tbInputId.Select(tbInputId.Text.Length, 1); if (SelectChangedItem != null) { SelectChangedItem(this, item); } }
private bool Form_LoadData(object sender, object data) { if (data != null && data is MonitorUnit) { MonitorUnit monitorUnit = data as MonitorUnit; tbMonitorUnitId.Text = string.Format("{0}", monitorUnit.MonitorUnitId); tbMonitorUnitName.Text = monitorUnit.MonitorUnitName; //cbPortfolioId.SelectedValue ComboBoxUtil.SetComboBoxSelect(cbPortfolioId, monitorUnit.PortfolioId.ToString()); ComboBoxUtil.SetComboBoxSelect(cbStockTemplate, monitorUnit.StockTemplateId.ToString()); AutoItem autoItem = new AutoItem { Id = monitorUnit.BearContract, Name = monitorUnit.BearContract }; acFuturesContracts.SetCurrentItem(autoItem); } return(true); }
private MonitorUnit GetMonitorUnit() { MonitorUnit monitorUnit = new MonitorUnit(); if (!string.IsNullOrEmpty(tbMonitorUnitId.Text) && tbMonitorUnitId.Text != "0") { int temp = 0; if (int.TryParse(tbMonitorUnitId.Text, out temp)) { monitorUnit.MonitorUnitId = temp; } } monitorUnit.MonitorUnitName = tbMonitorUnitName.Text; ComboOptionItem accountItem = (ComboOptionItem)cbAccountType.SelectedItem; if (accountItem != null && !string.IsNullOrEmpty(accountItem.Id)) { int temp = 0; if (int.TryParse(accountItem.Id, out temp)) { monitorUnit.EAccountType = (MonitorUnitAccountType)temp; } } ComboOptionItem portItem = (ComboOptionItem)cbPortfolioId.SelectedItem; if (portItem != null) { if (!string.IsNullOrEmpty(portItem.Id)) { int temp = 0; if (int.TryParse(portItem.Id, out temp)) { monitorUnit.PortfolioId = temp; } } if (portItem.Data != null && portItem.Data is Portfolio) { monitorUnit.PortfolioName = (portItem.Data as Portfolio).PortfolioName; } } ComboOptionItem tempItem = (ComboOptionItem)cbStockTemplate.SelectedItem; if (tempItem != null) { if (!string.IsNullOrEmpty(tempItem.Id)) { int temp = 0; if (int.TryParse(tempItem.Id, out temp)) { monitorUnit.StockTemplateId = temp; } } if (tempItem.Data != null && tempItem.Data is StockTemplate) { monitorUnit.StockTemplateName = (tempItem.Data as StockTemplate).TemplateName; } } AutoItem futuresItem = acFuturesContracts.GetCurrentItem(); if (futuresItem != null && !string.IsNullOrEmpty(futuresItem.Id)) { monitorUnit.BearContract = futuresItem.Id; } return(monitorUnit); }
internal static void FilledInTagList(string tagdef, ArrayList tagList, IResourceDependency res) { int idxBegin = 0, idxEnd = 0; idxBegin = tagdef.IndexOf("#}"); idxEnd = tagdef.LastIndexOf("{#"); tagdef = tagdef.Substring(idxBegin + 2, idxEnd - idxBegin - 2).Trim(); Regex regEx = new Regex(TagBase.TagDefinitionPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled); idxBegin = idxEnd = 0; MatchCollection mc = regEx.Matches(tagdef, idxBegin); HtmlTextTag htmlTag = null; while (mc.Count > 0) { Match m = mc[0]; idxEnd = m.Index; if (idxEnd > idxBegin) { htmlTag = new HtmlTextTag(tagdef.Substring(idxBegin, idxEnd - idxBegin)); tagList.Add(htmlTag); } TagBase tag = new TagBase(m.Value, m.Index, ref tagdef); //Util.Debug(tag.Category); if (tag.Category == TagCategory.AutoTag) { AutoItem item = AutoItem.Parse(tag); if (res.GetType() == typeof(PagerTag)) { item.CallerTag = (PagerTag)res; } tagList.Add(item); } else if (tag.Category == TagCategory.DefineTag) { //数据库标签定义格式为 {#%FieldName%#} if (res != null) { htmlTag = new HtmlTextTag(res.GetDefinition(tag.OuterDefineText).ToString()); tagList.Add(htmlTag); } } else if (tag.Category == TagCategory.CustomTag) { #region 数据定义标签内包含数据定义标签 DbStoredCustomTag dbTag = DbStoredCustomTag.Parse(tag); dbTag.SetResourceDependency(res); if (dbTag.IsExist == true) { htmlTag = new HtmlTextTag(dbTag.GetTagValue().ToString()); tagList.Add(htmlTag); } #endregion } else if (tag.Category == TagCategory.SystemTag) { string pageURLKey = ",FirstUrl,PreUrl,NextUrl,LastUrl,CurUrl,"; string tagName = tag.TagName.Trim('$'); if (pageURLKey.IndexOf("," + tagName + ",", StringComparison.InvariantCultureIgnoreCase) != -1) { tagName = tagName.ToLower(); PageUrl url = new PageUrl(tag.OuterDefineText); url.IsAutoItem = (res != null && res.GetType() == typeof(AutoItem)); url.SetResourceDependency(res); switch (tagName) { case "firsturl": url.UrlCategory = PageUrlCategory.FirstPage; break; case "preurl": url.UrlCategory = PageUrlCategory.PrePage; break; case "nexturl": url.UrlCategory = PageUrlCategory.NextPage; break; case "lasturl": url.UrlCategory = PageUrlCategory.LastPage; break; case "cururl": url.UrlCategory = PageUrlCategory.ThisPage; break; default: url.UrlCategory = PageUrlCategory.ThisPage; break; } tagList.Add(url); } else { SystemTag sys = new SystemTag(tag.OuterDefineText); //Util.Debug(false, res.GetType().ToString()); sys.SetResourceDependency(res); tagList.Add(sys); } } else { tagList.Add(tag); } //Util.Debug(false, "#####\n" + tag.OuterDefineText + "\n#####"); //TagList.Add(tag); idxBegin = tag.DefinedIndexEnd; mc = regEx.Matches(tagdef, idxBegin); } if (idxBegin < tagdef.Length) { htmlTag = new HtmlTextTag(tagdef.Substring(idxBegin)); tagList.Add(htmlTag); } }
/// <summary> /// 输入文本框,键盘按下松开事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TextBox_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { TextBox textBox = sender as TextBox; if (textBox == null) { return; } //清除tbName tbName.Text = string.Empty; ListBox listBox = this.lbDropdown; //上下左右键 if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Left) { if (listBox.SelectedIndex > 0) { listBox.SelectedIndex--; } } else if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Right) { if (listBox.SelectedIndex < listBox.Items.Count - 1) { listBox.SelectedIndex++; } } //回车 else if (e.KeyCode == Keys.Enter) { AutoItem item = listBox.SelectedItem as AutoItem; textBox.Text = item.Id; this.tbName.Text = item.Name; listBox.Visible = false; } else { if (!string.IsNullOrEmpty(textBox.Text)) { IList <AutoItem> dataSource = _dataManager.GetMatch(textBox.Text.Trim()); if (dataSource.Count > 0) { listBox.DataSource = dataSource; listBox.DisplayMember = "Id"; listBox.ValueMember = "Id"; listBox.Visible = true; } else { listBox.Visible = false; } } else { listBox.Visible = false; } } //光标定位到文本框最后 textBox.Select(textBox.Text.Length, 1); }
public void SetCurrentItem(AutoItem autoItem) { this.tbInputId.Text = autoItem.Id; this.tbName.Text = autoItem.Name; }
public static int ExeNonQuery(string ConnectionStringName, List <AutoObject> data) { int rowAff = 0; using (SqlConnection con = GetConnection(ConnectionStringName)) { SqlTransaction myTrans = null; try { con.Open(); myTrans = con.BeginTransaction(); SqlCommand cmd = new SqlCommand(); for (int i = 0; i < data.Count; i++) { #region Exe 1 SQL cmd.CommandText = data[i].SpName; cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = myTrans; //Get Param List <SqlParameter> lstParam = new List <SqlParameter>(); if (data[i].Items != null && data[i].Items.Count > 0) { lstParam = data[i].Items.ToSqlParameter(); cmd.Parameters.Clear(); cmd.Parameters.AddRange(lstParam.ToArray()); } int x = cmd.ExecuteNonQuery(); rowAff += x; if (x > 0) { SqlParameter Item = FindVersion(lstParam); AutoItem aItem = FindVersion(data[i]); if (aItem != null && Item != null) { aItem.Value = Item.Value; } } #endregion } myTrans.Commit(); for (int i = data.Count - 1; i >= 0; i--) { //if (data[i].SpName.ToLower().Contains("delete")) // data.RemoveAt(i); if (data[i].State == RowState.Delete) { data.RemoveAt(i); } } } catch (Exception ex) { myTrans.Rollback(); rowAff = 0; con.Close(); throw ex; } finally { con.Close(); } } return(rowAff); }