public static bool CopyCable(CableInfo cable, string username) { var newCbale = new CableInfo(cable) { CableName = cable.CableName + " 副本", CreateUser = username, ModifyDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; TmpCables.Add(newCbale); var circuits = TmpCircuits.Where(circuit => circuit.ParentCableId == cable.CableId).ToList(); foreach (var srcCircuit in circuits) { var circuit = new CircuitInfo(srcCircuit) { ParentCableId = newCbale.CableId, }; TmpCircuits.Add(circuit); } var dots = TmpDots.Where(dot => dot.ParentCableId == cable.CableId).ToList(); foreach (var srcDot in dots) { var dot = new DotInfo(srcDot) { ParentCableId = newCbale.CableId }; TmpDots.Add(dot); } return(true); }
public DotInfo(DotInfo info) { ParentCableId = info.ParentCableId; ParentCircuitId = info.ParentCircuitId; ParentPlugId = info.ParentPlugId; DotId = info.DotId; PhyAddr = info.PhyAddr; Name = info.Name; DotStyle = new Style { Type = info.DotStyle.Type, Size = info.DotStyle.Size, ForegroundColor = info.DotStyle.ForegroundColor, BackgroundColor = info.DotStyle.BackgroundColor }; Position = new Point(info.Position.X, info.Position.Y); }
public static bool SelectDots(out List <DotInfo> dots) { const string querySql = "SELECT * FROM points"; DataTable dt; dots = new List <DotInfo>(); if (!QueryData(querySql, out dt)) { return(false); } try { for (var i = 0; i < dt.Rows.Count; i++) { var tmpDotInfo = new DotInfo { ParentCableId = Convert.ToInt32(dt.Rows[i][0].ToString()), DotId = Convert.ToInt32(dt.Rows[i][1].ToString()), ParentPlugId = Convert.ToInt32(dt.Rows[i][2].ToString()), ParentCircuitId = Convert.ToInt32(dt.Rows[i][3].ToString()), PhyAddr = dt.Rows[i][4].ToString(), Name = dt.Rows[i][5].ToString(), DotStyle = new Style { Type = Convert.ToInt32(dt.Rows[i][6].ToString()), Size = Convert.ToInt32(dt.Rows[i][7].ToString()), ForegroundColor = (Color)ColorConverter.ConvertFromString(dt.Rows[i][8].ToString()), BackgroundColor = (Color)ColorConverter.ConvertFromString(dt.Rows[i][9].ToString()) }, Position = new Point(Convert.ToInt32(dt.Rows[i][10].ToString()), Convert.ToInt32(dt.Rows[i][11].ToString())) }; dots.Add(tmpDotInfo); } } catch (Exception e) { LogControl.LogError(e); } return(true); }
public static bool AddDot(DotInfo dot) { TmpDots.Add(dot); return(true); }