/// <summary> /// 更新一条数据 /// </summary> public bool Update(AMS_CommandListModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update AMS_CommandList set "); strSql.Append("SchoolId=@SchoolId,"); strSql.Append("Command=@Command,"); strSql.Append("CommandId=@CommandId,"); strSql.Append("ReleaseTime=@ReleaseTime,"); strSql.Append("FinishTime=@FinishTime,"); strSql.Append("FinishFlag=@FinishFlag"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@SchoolId", SqlDbType.Int, 4), new SqlParameter("@Command", SqlDbType.Int, 4), new SqlParameter("@CommandId", SqlDbType.Int, 4), new SqlParameter("@ReleaseTime", SqlDbType.DateTime), new SqlParameter("@FinishTime", SqlDbType.DateTime), new SqlParameter("@FinishFlag", SqlDbType.Int, 4), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.SchoolId; parameters[1].Value = (int)model.Command; parameters[2].Value = model.CommandId; parameters[3].Value = model.ReleaseTime; parameters[4].Value = model.FinishTime; parameters[5].Value = (int)model.FinishFlag; parameters[6].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(AMS_CommandListModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AMS_CommandList("); strSql.Append("SchoolId,Command,CommandId,ReleaseTime,FinishTime,FinishFlag)"); strSql.Append(" values ("); strSql.Append("@SchoolId,@Command,@CommandId,@ReleaseTime,@FinishTime,@FinishFlag)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@SchoolId", SqlDbType.Int, 4), new SqlParameter("@Command", SqlDbType.Int, 4), new SqlParameter("@CommandId", SqlDbType.Int, 4), new SqlParameter("@ReleaseTime", SqlDbType.DateTime), new SqlParameter("@FinishTime", SqlDbType.DateTime), new SqlParameter("@FinishFlag", SqlDbType.Bit, 1) }; parameters[0].Value = model.SchoolId; parameters[1].Value = (int)model.Command; parameters[2].Value = model.CommandId; parameters[3].Value = model.ReleaseTime; parameters[4].Value = model.FinishTime; parameters[5].Value = (int)model.FinishFlag; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }