/// <summary> /// 增加一条数据 /// </summary> public int Add(IPSP.Model.T_MonitorInCase model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_MonitorInCase("); strSql.Append("n_MonitorID,n_CaseID,n_ProcessID,s_IsMainCase)"); strSql.Append(" values ("); strSql.Append("@n_MonitorID,@n_CaseID,@n_ProcessID,@s_IsMainCase)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@n_MonitorID", SqlDbType.Int, 4), new SqlParameter("@n_CaseID", SqlDbType.Int, 4), new SqlParameter("@n_ProcessID", SqlDbType.Int, 4), new SqlParameter("@s_IsMainCase", SqlDbType.NVarChar, 1) }; parameters[0].Value = model.n_MonitorID; parameters[1].Value = model.n_CaseID; parameters[2].Value = model.n_ProcessID; parameters[3].Value = model.s_IsMainCase; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public IPSP.Model.T_MonitorInCase DataRowToModel(DataRow row) { IPSP.Model.T_MonitorInCase model = new IPSP.Model.T_MonitorInCase(); if (row != null) { if (row["n_ID"] != null && row["n_ID"].ToString() != "") { model.n_ID = int.Parse(row["n_ID"].ToString()); } if (row["n_MonitorID"] != null && row["n_MonitorID"].ToString() != "") { model.n_MonitorID = int.Parse(row["n_MonitorID"].ToString()); } if (row["n_CaseID"] != null && row["n_CaseID"].ToString() != "") { model.n_CaseID = int.Parse(row["n_CaseID"].ToString()); } if (row["n_ProcessID"] != null && row["n_ProcessID"].ToString() != "") { model.n_ProcessID = int.Parse(row["n_ProcessID"].ToString()); } if (row["s_IsMainCase"] != null) { model.s_IsMainCase = row["s_IsMainCase"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(IPSP.Model.T_MonitorInCase model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_MonitorInCase set "); strSql.Append("s_IsMainCase=@s_IsMainCase"); strSql.Append(" where n_ID=@n_ID"); SqlParameter[] parameters = { new SqlParameter("@s_IsMainCase", SqlDbType.NVarChar, 1), new SqlParameter("@n_ID", SqlDbType.Int, 4), new SqlParameter("@n_MonitorID", SqlDbType.Int, 4), new SqlParameter("@n_CaseID", SqlDbType.Int, 4), new SqlParameter("@n_ProcessID", SqlDbType.Int, 4) }; parameters[0].Value = model.s_IsMainCase; parameters[1].Value = model.n_ID; parameters[2].Value = model.n_MonitorID; parameters[3].Value = model.n_CaseID; parameters[4].Value = model.n_ProcessID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public IPSP.Model.T_MonitorInCase GetModel(int n_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 n_ID,n_MonitorID,n_CaseID,n_ProcessID,s_IsMainCase from T_MonitorInCase "); strSql.Append(" where n_ID=@n_ID"); SqlParameter[] parameters = { new SqlParameter("@n_ID", SqlDbType.Int, 4) }; parameters[0].Value = n_ID; IPSP.Model.T_MonitorInCase model = new IPSP.Model.T_MonitorInCase(); 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(IPSP.Model.T_MonitorInCase model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(IPSP.Model.T_MonitorInCase model) { return(dal.Add(model)); }