public WasteCover(String name, Point point, String info) : base(name, point, info) { if (juncInfo == null) { juncInfo = new CJuncInfo(); juncInfo.Junc_Category = (int)JUNCTYPE.JUNC_WASTE; } }
private ObservableCollection<JuncMesage> GetData(int id) { var Datas = new ObservableCollection<JuncMesage>(); SelectCmd scmd = new SelectCmd(); JuncRev rev = new JuncRev(); rev.ID = id; scmd.SetReceiver(rev); scmd.Execute(); if (rev.ListJunc == null || rev.ListJunc.Count <= 0) return null; mJunc = rev.ListJunc.ElementAt(0); mJuncext = rev.ListJuncExt.ElementAt(0); Datas.Add(new JuncMesage { ItemName = "井盖名称", ValueName = mJunc.JuncName }); Datas.Add(new JuncMesage { ItemName = "道路名称", ValueName = mJuncext.Lane_Way }); Datas.Add(new JuncMesage { ItemName = "经度", ValueName = Convert.ToString(mJunc.X_Coor) }); Datas.Add(new JuncMesage { ItemName = "纬度", ValueName = Convert.ToString(mJunc.Y_Coor) }); Datas.Add(new JuncMesage { ItemName = "检查井类别", ValueName = GetCategoryName(mJunc.Junc_Category) }); Datas.Add(new JuncMesage { ItemName = "检查井类型", ValueName = GetType(mJunc.Junc_Type) }); Datas.Add(new JuncMesage { ItemName = "检查井形式", ValueName = GetStyle(mJunc.Junc_Style) }); Datas.Add(new JuncMesage { ItemName = "井深", ValueName = GetDepth(mJunc.Depth) }); Datas.Add(new JuncMesage { ItemName = "井盖所处的地面高程", ValueName = GetDepth(mJunc.Surface_Ele) }); Datas.Add(new JuncMesage { ItemName = "数据来源", ValueName = GetDataSource(mJunc.DataSource) }); Datas.Add(new JuncMesage { ItemName = "数据填报单位", ValueName = mJunc.ReportDept }); Datas.Add(new JuncMesage { ItemName = "数据填报时间", ValueName = Convert.ToString(mJunc.Record_Date) }); Datas.Add(new JuncMesage { ItemName = "管道是否暗接", ValueName = bool2str(mJunc.Junc_Darkjoint) }); Datas.Add(new JuncMesage { ItemName = "污水是否直排", ValueName = bool2str(mJunc.Sewage_Line) }); Datas.Add(new JuncMesage { ItemName = "井盖错误", ValueName = bool2str(mJunc.Junc_Error) }); Datas.Add(new JuncMesage { ItemName = "CCTV检测编号", ValueName = mJunc.CCTV_CheckCode }); Datas.Add(new JuncMesage { ItemName = "数据是否完整", ValueName = bool2str(mJunc.FullData) }); Datas.Add(new JuncMesage { ItemName = "数据缺失原因", ValueName = mJunc.LoseReson }); Datas.Add(new JuncMesage { ItemName = "A上游井口至管顶距离", ValueName = GetDepth(mJunc.Dis[0]) }); Datas.Add(new JuncMesage { ItemName = "A上游井口至管底距离", ValueName = GetDepth(mJunc.Dis[1]) }); Datas.Add(new JuncMesage { ItemName = "A下游井口至管顶距离", ValueName = GetDepth(mJunc.Dis[2]) }); Datas.Add(new JuncMesage { ItemName = "A下游井口至管底距离", ValueName = GetDepth(mJunc.Dis[3]) }); Datas.Add(new JuncMesage { ItemName = "B上游井口至管顶距离", ValueName = GetDepth(mJunc.Dis[4]) }); Datas.Add(new JuncMesage { ItemName = "B上游井口至管底距离", ValueName = GetDepth(mJunc.Dis[5]) }); Datas.Add(new JuncMesage { ItemName = "B下游井口至管顶距离", ValueName = GetDepth(mJunc.Dis[6]) }); Datas.Add(new JuncMesage { ItemName = "B下游井口至管底距离", ValueName = GetDepth(mJunc.Dis[7]) }); Datas.Add(new JuncMesage { ItemName = "备注", ValueName = mJuncext.Remark }); return Datas; }
private List<CJuncInfo> Select(string cmd) { List<CJuncInfo> listjunc = new List<CJuncInfo>(); MySqlCommand com; MySqlDataReader reader; try { connect.Open(); com = new MySqlCommand(cmd, connect); reader = com.ExecuteReader(); while (reader.Read()) { CJuncInfo juncinfo = new CJuncInfo(); int i = 0; string tmp; juncinfo.ID = Convert.ToInt32(reader[i++].ToString()); juncinfo.JuncName = reader[i++].ToString(); juncinfo.SystemID = reader[i++].ToString(); juncinfo.WorkingID = reader[i++].ToString(); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.X_Coor = Convert.ToDouble(tmp); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.Y_Coor = Convert.ToDouble(tmp); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.Junc_Category = Convert.ToInt32(tmp); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.Junc_Type = Convert.ToInt32(tmp); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.Junc_Style = Convert.ToInt32(tmp); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.Depth = Convert.ToDouble(tmp); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.Surface_Ele = Convert.ToDouble(tmp); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.DataSource = Convert.ToInt32(tmp); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.Record_Date = Convert.ToDateTime(tmp); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.ReportDept = tmp; tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.ReportDate = Convert.ToDateTime(tmp); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.Junc_Darkjoint = Convert.ToBoolean(Convert.ToInt32(tmp)); //for mysql tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.Sewage_Line = Convert.ToBoolean(Convert.ToInt32(tmp)); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.Junc_Error = Convert.ToBoolean(Convert.ToInt32(tmp)); juncinfo.CCTV_CheckCode = reader[i++].ToString(); tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.FullData = Convert.ToBoolean(Convert.ToInt32(tmp)); juncinfo.LoseReson = reader[i++].ToString(); for (int j = 0; j < 8;j++ ) { tmp = reader[i++].ToString(); if (tmp != null && tmp.Length > 0) juncinfo.Dis[j] = Convert.ToDouble(tmp); } listjunc.Add(juncinfo); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); return null; } finally { connect.Close(); } return listjunc; }
public bool Delete_JuncInfo(CJuncInfo junc) { List<string> listcmd = new List<string>(); try { string cmd = "DELETE FROM JuncInfo where ID = " + junc.ID; listcmd.Add(cmd); ExectueCmd(listcmd); } catch (System.Exception ex) { Console.WriteLine(ex.Message); return false; } return true; }
/// <summary> /// 插入junction 并返回其在数据库中的ID /// </summary> /// <param name="junc"></param> /// <returns></returns> public bool Insert_JuncInfo(ref CJuncInfo junc) { MySqlDataReader reader; string strcmd = "INSERT INTO JuncInfo(JuncName,SystemID,WorkingID,X_Coor,Y_Coor,Junc_Category,Junc_Type," + "Junc_Style,Depth,Surface_Ele,DataSource,Record_Date,ReportDept,ReportDate,Junc_Darkjoint,"+ "Sewage_Line,Junc_Error,CCTV_CheckCode,FullData,LoseReson,AUpTop,AUpBottom,ADownTop,ADownBottom," + "BUpTop,BUpBottom,BDownTop,BDownBottom) values('" + junc.JuncName + "','" + junc.SystemID + "','"+junc.WorkingID+"','" + junc.X_Coor + "','" + junc.Y_Coor + "', " + junc.Junc_Category + " , " + junc.Junc_Type + " , " +junc.Junc_Style + " ,'" + junc.Depth + "','" + junc.Surface_Ele + "', " + junc.DataSource + " ,'" + Convert.ToString(junc.Record_Date) + "','" + junc.ReportDept + "','" + Convert.ToString(junc.ReportDate) + "', "+Convert.ToString(junc.Junc_Darkjoint)+"," +junc.Sewage_Line+","+junc.Junc_Error+",'"+junc.CCTV_CheckCode+"',"+junc.FullData+",'"+junc.LoseReson+"','"+junc.Dis[0] +"','"+junc.Dis[1]+"','"+junc.Dis[2]+"','"+junc.Dis[3]+"','"+junc.Dis[4]+"','"+junc.Dis[5]+"','"+junc.Dis[6]+"','"+junc.Dis[7]+"')"; try { connect.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = connect; cmd.CommandType = CommandType.Text; cmd.CommandText = strcmd; //strcmd = "SELECT MAX(ID) AS MAXID FROM JuncInfo"; cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT MAX(ID) AS MAXID FROM JuncInfo"; reader = cmd.ExecuteReader(); reader.Read(); junc.ID = Convert.ToInt32(reader[0].ToString()); } catch (System.Exception ex) { Console.WriteLine(ex.Message); return false; } finally { connect.Close(); } return true; }
//返回插入junction的id protected int InsterDB(Cover c) { if (c == null) return 0; //change the coordinate Mercator to WGS84 Coords.Point p = new Coords.Point(); p.x = c.Location.X; p.y = c.Location.Y; p = Coords.Mercator2WGS84(p); //store to CJuncInfo info = new CJuncInfo(); info.X_Coor = p.x + Constants.COOR_X_OFFSET; info.Y_Coor = p.y + Constants.COOR_Y_OFFSET; info.Junc_Category = c.juncInfo.Junc_Category; //数据库操作 TJuncInfo juncinfo = new TJuncInfo(App._dbpath, App.PassWord); TJuncExtInfo juncextinfo = new TJuncExtInfo(App._dbpath, App.PassWord); if (!juncinfo.Insert_JuncInfo(ref info)) { return 0; } CJuncExtInfo extinfo = new CJuncExtInfo(); extinfo.JuncID = info.ID; juncextinfo.Insert_JuncExtInfo(ref extinfo); return info.ID; }
private bool SaverTodb(List<JuncSheetData> list) { if (list == null || list.Count <= 0) return false; QuickInsert qicm = new QuickInsert(); JuncRev rev = new JuncRev(); rev.ListJunc = new List<CJuncInfo>(); rev.ListJuncExt = new List<CJuncExtInfo>(); foreach (JuncSheetData data in list) { CJuncInfo info = new CJuncInfo(); CJuncExtInfo extinfo = new CJuncExtInfo(); extinfo.Lane_Way = data.RoadName; info.JuncName = data.JuncName; info.Junc_Category = GetCategory(data.JuncCategory); info.Junc_Type = GetType(data.JuncType); info.Y_Coor = data.Latitude; info.X_Coor = data.Longitude; info.Surface_Ele = data.Height; info.Junc_Style = GetStyle(data.JuncStyle); info.Depth = data.Depth; info.Junc_Darkjoint = data.JuncDarkjoint; info.Sewage_Line = data.SewageLine; info.Junc_Error = data.JuncError; info.CCTV_CheckCode = data.CCTV_CheckCode; info.DataSource = GetDataSource(data.DataSource); info.Record_Date = data.DataTime; info.ReportDept = data.RecordDept; info.ReportDate = data.RecordTime; for (int i = 0; i < 8;i++ ) { info.Dis[i] = data.Dis[i]; } info.FullData = data.DataFull; info.LoseReson = data.LoseReson; extinfo.Remark = data.Remark; rev.ListJunc.Add(info); rev.ListJuncExt.Add(extinfo); } qicm.SetReceiver(rev); qicm.Execute(); return true; }