public List <int> AllDensity = new List <int>();//读取所有密度值,用来在Assessform中判断可视化条形图大小 /// <summary> /// 计算所有站的列车密度 /// </summary> public Dictionary <List <string>, List <int> > GetTrainDensity(DataManager dmm)//列车密度表_返回形式(<站名,站名> -> <上行列车数,下行列车数>) { //调用方法实现PaintTool中str1的读取 完成密度值的计算 DataManager dm = dmm; PaintTool pt = new PaintTool(); PaintForm pf = new PaintForm(); int ix = dm.stationDrawList.Count; List <double> staMile = new List <double>(); for (int i = 0; i < ix; i++) { staMile.Add(dm.stationDrawList[i].totalMile); } pt.Branch(dm.stationDrawStringList, staMile, pf.bmp.Width, pf.bmp.Height); Dictionary <List <string>, List <int> > TrainDensity = new Dictionary <List <string>, List <int> >(); for (int jjj = 1; jjj < pt.str1.Count + 1; jjj++) { List <string> StationName = pt.str1[jjj];//读取各个线路的站名列表 for (int i = 0; i < StationName.Count - 1; i++) { List <string> Section = new List <string>();//读取区间名称 Section.Add(StationName[i]); Section.Add(StationName[i + 1]); List <int> Density = new List <int>(); int DensityUp = 0; int DensityDown = 0; foreach (Train aTrain in dm.UpTrainDic.Values)//上行列车 { for (int j = 0; j < aTrain.staList.Count - 1; j++) { if (StationName[i + 1] == aTrain.staList[j] && StationName[i] == aTrain.staList[j + 1])//判断列车经过车站顺序符合则区间列车密度加1 { DensityUp++; } } } Density.Add(DensityUp); AllDensity.Add(DensityUp); foreach (Train aTrain in dm.DownTrainDic.Values)//下行列车 { for (int j = 0; j < aTrain.staList.Count - 1; j++) { if (StationName[i] == aTrain.staList[j] && StationName[i + 1] == aTrain.staList[j + 1])//判断列车经过车站顺序符合则区间列车密度加1 { DensityDown++; } } } Density.Add(DensityDown); AllDensity.Add(DensityDown); TrainDensity.Add(Section, Density); } } return(TrainDensity); }
public void login_Click(object sender, EventArgs e) { string Accessfilename = @"\\注册用户表.mdb"; string Constr = "Provider=Microsoft.ace.OLEDB.12.0;Data Source=" + Application.StartupPath + Accessfilename; OleDbConnection con = new OleDbConnection(Constr); con.Open(); string selectsql1 = "Select * from UsersDat where Users='" + textBox1.Text.ToString() + "'"; string selectsql2 = "Select * from PasswordDat where password='******'"; OleDbCommand odc1 = new OleDbCommand(selectsql1, con); OleDbCommand odc2 = new OleDbCommand(selectsql2, con); OleDbDataReader odr1; OleDbDataReader odr2; odr1 = odc1.ExecuteReader(); odr2 = odc2.ExecuteReader(); if (odr1.Read() && odr2.Read()) { PaintForm paintForm = new PaintForm(); paintForm.Owner = this; paintForm.Show(); } else { MessageBox.Show("用户名或密码错误!"); return; } con.Close(); if (textBox1.Text.Trim() == "") { MessageBox.Show("用户名不能为空!"); } if (textBox2.Text.Trim() == "") { MessageBox.Show("密码不能为空!"); } }