WPF 开发备忘录
运营日:
select t.* |
;f:datetime -时间日期格式
;f:fen -表示单价分
--
在查询结果后面增加一行自定义数据
union all
select distinct ' ' as name, a from v
instr(字段,'关键字')>0
例如 like %关键字% 等同于 instr(字段,'关键字')>0
ComboBox 静态值绑定
No.1
[数据字典方式]
-----
#>前台代码:
<ComboBox Name="name" ItemsSource="{Binding}" />
#>后台代码:
public MainWindow()
{
InitializeComponent();
Dictionary<int, string> mydic = new Dictionary<int, string>()
{
{1,"a"},
{2,"b"},
{3,"c"}
};
combobox.ItemsSource = mydic;
combobox.SelectedValuePath = "Key";
combobox.DisplayMemberPath = "Value";
payId.SelectedIndex = 0;
}
No.1
[增加一项]
-----
#>VM代码:
public List<BasiStationInfo> StationInfo { get; private set; }
public void GetStationInfo()
{
string line_id = SysConfig.GetSysConfig().LocalParamsConfig.LineCode;
string sql = string.Format("select * from basi_station_info where line_id='{0}'", line_id);
StationInfo = DBCommon.Instance.GetTModelValue<BasiStationInfo>(sql);
BasiStationInfo info = new BasiStationInfo();
info.station_id = "0000";
info.station_cn_name = "全部车站";
StationInfo.Insert(0, info);
}
No.2
-----
#>VM代码:
public List<BasiStationInfo> StationInfo { get; private set; }
string sqlStation = "select * from basi_station_info t ";
this.StationInfo = DBCommon.Instance.GetTModelValue<BasiStationInfo>(sqlStation);
if (this.StationInfo == null)
this.StationInfo = new List<BasiStationInfo>();
this.StationInfo.Insert(0, new BasiStationInfo() { station_id = "全部车站", station_cn_name = "全部车站" });
this.station_id = "全部车站";
No.3
[代码示例]
-----
#>VM代码:
private List<ModeCodeInfo> modeInfo;
/// <summary>
/// 发起方
/// </summary>
public List<ModeCodeInfo> ModeInfo
{
get { return modeInfo; }
set { modeInfo = value; NotifyPropertyChanged("ModeInfo"); }
}
public void GetModeInfo()
{
this.ModeInfo.Clear();
this.ModeInfo.Add(new ModeCodeInfo() { set_origin_id = "全部", set_origin = "全部" });
this.ModeInfo.Add(new ModeCodeInfo() { set_origin_id = "FAS", set_origin = "1" });
this.ModeInfo.Add(new ModeCodeInfo() { set_origin_id = "SC", set_origin = "2" });
this.SetOriginID = "全部";
}
#>Model代码:
public class ModeCodeInfo
{
private string _set_origin;
/// <summary>
/// 发起方
/// </summary>
public string set_origin
{
get { return _set_origin; }
set { _set_origin = value; NotifyPropertyChanged("set_origin"); }
}
private string _set_origin_id;
/// <summary>
/// 发起方名称
/// </summary>
public string set_origin_id
{
get { return _set_origin_id; }
set { _set_origin_id = value; NotifyPropertyChanged("set_origin_id"); }
}
public override string ToString()
{
return set_origin_id;
}
}