public void Delete(MonthModel month) { using (OleDbConnection connection = new OleDbConnection(Tool.ConPath)) { connection.Open(); string sql = "Delete MonthReport where ID=@ID"; OleDbCommand command = new OleDbCommand(sql, connection); command.Parameters.AddWithValue("@ID", month.ID); command.ExecuteNonQuery(); Tool.SaveOpr(new LogModel() { Title = month.Title + " 删除", dateTime = DateTime.Now }); } }
public void Create(MonthModel month) { using (OleDbConnection connection = new OleDbConnection(Tool.ConPath)) { connection.Open(); string sql = "INSERT INTO MonthReport(Title,MonthDay) values(@Title,@MonthDay)"; OleDbCommand command = new OleDbCommand(sql, connection); command.Parameters.AddWithValue("@Title", month.Title); command.Parameters.AddWithValue("@MonthDay", month.MonthDay); command.ExecuteNonQuery(); Tool.SaveOpr(new LogModel() { Title = month.Title + " 添加", dateTime = DateTime.Now }); } }
public void UpDate(MonthModel month) { using (OleDbConnection connection = new OleDbConnection(Tool.ConPath)) { connection.Open(); string sql = "UPDATE MonthReport Set Title=@Title,MonthDay=@MonthDay where ID=@ID"; OleDbCommand command = new OleDbCommand(sql, connection); command.Parameters.AddWithValue("@ID", month.ID); command.Parameters.AddWithValue("@Title", month.Title); command.Parameters.AddWithValue("@MonthDay", month.MonthDay); command.ExecuteNonQuery(); Tool.SaveOpr(new LogModel() { Title = month.Title + " 修改", dateTime = DateTime.Now }); } }