/// <summary> /// 增加一条数据 /// </summary> public bool Add(ControllerEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Controller("); strSql.Append("Cn_ID,DTU_ID,Cn_addr,Cp_ID,Cn_longitude,Cn_dimensionality)"); strSql.Append(" values ("); strSql.Append("@Cn_ID,@DTU_ID,@Cn_addr,@Cp_ID,@Cn_longitude,@Cn_dimensionality)"); SqlParameter[] parameters = { new SqlParameter("@Cn_ID", SqlDbType.NVarChar, 50), new SqlParameter("@DTU_ID", SqlDbType.NVarChar, 50), new SqlParameter("@Cn_addr", SqlDbType.Int, 4), new SqlParameter("@Cp_ID", SqlDbType.Int, 4), new SqlParameter("@Cn_longitude", SqlDbType.NVarChar, 50), new SqlParameter("@Cn_dimensionality", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.Cn_ID; parameters[1].Value = model.DTU_ID; parameters[2].Value = model.Cn_addr; parameters[3].Value = model.Cp_ID; parameters[4].Value = model.Cn_longitude; parameters[5].Value = model.Cn_dimensionality; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ControllerEntity DataRowToModel(DataRow row) { ControllerEntity model = new ControllerEntity(); if (row != null) { if (row["Cn_ID"] != null) { model.Cn_ID = row["Cn_ID"].ToString(); } if (row["DTU_ID"] != null) { model.DTU_ID = row["DTU_ID"].ToString(); } if (row["Cn_addr"] != null && row["Cn_addr"].ToString() != "") { model.Cn_addr = int.Parse(row["Cn_addr"].ToString()); } if (row["Cp_ID"] != null && row["Cp_ID"].ToString() != "") { model.Cp_ID = int.Parse(row["Cp_ID"].ToString()); } if (row["Cn_longitude"] != null) { model.Cn_longitude = row["Cn_longitude"].ToString(); } if (row["Cn_dimensionality"] != null) { model.Cn_dimensionality = row["Cn_dimensionality"].ToString(); } } return(model); }
internal void UpdateData(int iD1, int iD2, int lawID, float coef) { ControllerEntity ce = parent.boardObject.GetComponent <MIK51>().controllers[iD1]; if (lawID != GetTypeLawInt(ce.laws[iD2].GetType())) { ce.laws[iD2] = (ControlLaw)ce.gameObject.AddComponent(GetTypeLaw(lawID)); } ce.laws[iD2].coefficient = coef; }
public void AddNewPath() { ControlPath p = Instantiate(prefab, container); p.panel = this; controlPaths.Add(p); p.UpdateID(controlPaths.Count - 1); ControllerEntity entity = Instantiate(ePrefab, parent.boardObject.transform); p.schemeObject.boardObject = entity.gameObject; parent.boardObject.GetComponent <MIK51>().controllers.Add(entity); }
public void AddLaw() { LawEditor le = Instantiate(lawPrefab, container); le.path = this; laws.Add(le); le.ID = laws.IndexOf(le); ControllerEntity ce = schemeObject.boardObject.GetComponent <ControllerEntity>(); PController con = (PController)ce.gameObject.AddComponent(typeof(PController)); con.coefficient = 1; ce.laws.Add(con); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ControllerEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Controller set "); strSql.Append("DTU_ID=@DTU_ID,"); strSql.Append("Cn_addr=@Cn_addr,"); strSql.Append("Cp_ID=@Cp_ID,"); strSql.Append("Cn_longitude=@Cn_longitude,"); strSql.Append("Cn_dimensionality=@Cn_dimensionality"); strSql.Append(" where Cn_ID=@Cn_ID "); SqlParameter[] parameters = { new SqlParameter("@DTU_ID", SqlDbType.NVarChar, 50), new SqlParameter("@Cn_addr", SqlDbType.Int, 4), new SqlParameter("@Cp_ID", SqlDbType.Int, 4), new SqlParameter("@Cn_longitude", SqlDbType.NVarChar, 50), new SqlParameter("@Cn_dimensionality", SqlDbType.NVarChar, 50), new SqlParameter("@Cn_ID", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.DTU_ID; parameters[1].Value = model.Cn_addr; parameters[2].Value = model.Cp_ID; parameters[3].Value = model.Cn_longitude; parameters[4].Value = model.Cn_dimensionality; parameters[5].Value = model.Cn_ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ControllerEntity GetModel(string Cn_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Cn_ID,DTU_ID,Cn_addr,Cp_ID,Cn_longitude,Cn_dimensionality from Controller "); strSql.Append(" where Cn_ID=@Cn_ID "); SqlParameter[] parameters = { new SqlParameter("@Cn_ID", SqlDbType.NVarChar, 50) }; parameters[0].Value = Cn_ID; ControllerEntity model = new ControllerEntity(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ControllerEntity model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(ControllerEntity model) { return(dal.Add(model)); }