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