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 static bool AddCable(CableInfo cable) { TmpCables.Add(cable); var circuitInfo = new CircuitInfo { ParentCableId = cable.CableId, CircuitId = 0, Name = "空点" }; AddCircuit(circuitInfo); return(true); }
public CircuitInfo(CircuitInfo info) { ParentCableId = info.ParentCableId; CircuitId = info.CircuitId; Name = info.Name; Remark = info.Remark; LineStyle = new Style { Type = info.LineStyle.Type, Size = info.LineStyle.Size, ForegroundColor = info.LineStyle.ForegroundColor, BackgroundColor = info.LineStyle.BackgroundColor }; DotStyle = new Style { Type = info.DotStyle.Type, Size = info.DotStyle.Size, ForegroundColor = info.DotStyle.ForegroundColor, BackgroundColor = info.DotStyle.BackgroundColor }; }
public static bool SelectCircuits(out List <CircuitInfo> circuits) { const string querySql = "SELECT * FROM circuits"; DataTable dt; circuits = new List <CircuitInfo>(); if (!QueryData(querySql, out dt)) { return(false); } for (var i = 0; i < dt.Rows.Count; i++) { var tmpCircuitInfo = new CircuitInfo { ParentCableId = Convert.ToInt32(dt.Rows[i][0].ToString()), CircuitId = Convert.ToInt32(dt.Rows[i][1].ToString()), Name = dt.Rows[i][2].ToString(), Remark = dt.Rows[i][3].ToString(), LineStyle = new Style { Type = Convert.ToInt32(dt.Rows[i][4].ToString()), Size = Convert.ToInt32(dt.Rows[i][5].ToString()), ForegroundColor = (Color)ColorConverter.ConvertFromString(dt.Rows[i][6].ToString()), BackgroundColor = Colors.Transparent }, DotStyle = new Style { Type = Convert.ToInt32(dt.Rows[i][7].ToString()), Size = Convert.ToInt32(dt.Rows[i][8].ToString()), ForegroundColor = (Color)ColorConverter.ConvertFromString(dt.Rows[i][9].ToString()), BackgroundColor = (Color)ColorConverter.ConvertFromString(dt.Rows[i][10].ToString()) } }; circuits.Add(tmpCircuitInfo); } return(true); }
public static bool AddCircuit(CircuitInfo circuit) { TmpCircuits.Add(circuit); return(true); }